Karsten Bruns
10/17/2023, 1:21 PMkapa.ai
10/17/2023, 1:21 PMHttpStream class in Airbyte's Python CDK. You can create a custom stream where you initialize the stream with a list of IDs and then use each ID for each API request. Here's a simplified example based on the code provided in the [forum post](https://discuss.airbyte.io/t/3383): python class CustomStream(HttpStream): url_base = "Your_API_URL" primary_key = "id" def __init__(self, ids: list, **kwargs): super().__init__(**kwargs) self.ids = ids def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: if not self.ids: return None else: return {"next": self.ids.pop(0)} def path(self, **kwargs) -> str: return f"items/{self.ids[0]}" def parse_response(self, response: requests.Response, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None,) -> Iterable[Mapping]: if response.status_code == 200: return [response.json()] elif response.status_code == 404: return [] In this example, CustomStream is initialized with a list of IDs. The next_page_token method pops an ID from the list for each API request until the list is empty. The path method uses the first ID in the list for the API request. The parse_response method parses the API response. Please note that this is a simplified example and you might need to adjust it according to your specific API and requirements. For more information on how to use the HttpStream class, you can refer to the [Airbyte's Python CDK documentation](https://docs.airbyte.com/connector-development/cdk-python/http-streams).Karsten Bruns
10/17/2023, 1:33 PMKarsten Bruns
10/17/2023, 2:16 PMkapa.ai
10/17/2023, 2:16 PMkapa.ai
10/17/2023, 2:17 PMshould_retry and the backoff_time methods. If you want to customize this behavior, you can override these methods. Here is an [example](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-slack/source_slack/source.py#L72) from the Slack API. However, it's important to note that Airbyte will always attempt to make as many requests as possible and only slow down if there are errors. It is not currently possible to specify a rate limit Airbyte should adhere to when making requests. If you're encountering issues with a specific connector, it would be helpful to check the specific documentation for that connector, as some have specific rate limits or performance considerations. For example, [Weatherstack](https://docs.airbyte.com/integrations/sources/weatherstack) allows 250 calls per month, [Mailchimp](https://docs.airbyte.com/integrations/sources/mailchimp) enforces a maximum of 10 simultaneous connections, and [Google Sheets](https://docs.airbyte.com/integrations/destinations/google-sheets) has a rate limit of 100 requests per 100 seconds per user and 500 requests per 100 seconds per project. If you continue to experience issues, you can [create an issue](https://github.com/airbytehq/airbyte/issues) on the Airbyte GitHub page.Karsten Bruns
10/17/2023, 2:26 PMkapa.ai
10/17/2023, 2:26 PMkapa.ai
10/17/2023, 2:27 PMsourceId and destinationId values from the first API call in the request body of the subsequent calls. Here's an example of how you might do this: python var client = new RestClient("<https://api.airbyte.com/v1/connections>"); var request = new RestRequest(); request.AddHeader("accept", "application/json"); request.AddHeader("content-type", "application/json"); request.AddHeader("Authorization", "Bearer {YourApiKey}"); request.AddParameter("application/json", "{\"sourceId\":\"YourSourceID\",\"destinationId\":\"YourDestinationID\",\"name\":\"AzPostgres-AzBlob2\",\"schedule\":{\"scheduleType\":\"manual\"},\"dataResidency\":\"auto\",\"namespaceDefinition\":\"destination\",\"namespaceFormat\":null,\"nonBreakingSchemaUpdatesBehavior\":\"ignore\",\"configurations\":{\"streams\":[{\"syncMode\":\"full_refresh_overwrite\",\"name\":\"YourTableName\"}]}}", ParameterType.RequestBody); var response = client.ExecutePost(request); In this example, YourSourceID and YourDestinationID would be replaced with the IDs you received from the first API call. However, please note that the specifics of how you would do this can vary depending on the API you're working with and the programming language you're using. For more detailed information, you may want to refer to the [Airbyte documentation](https://docs.airbyte.com/connector-development/connector-builder-ui/connector-builder-compatibility) or the API documentation of the specific service you're working with.Karsten Bruns
10/17/2023, 2:29 PMkapa.ai
10/17/2023, 2:29 PMkapa.ai
10/17/2023, 2:29 PMHttpStream class in your source.py file. You can create a new class for the second API call that inherits from HttpStream and uses the IDs from the first API call in the request body. Here's a simplified example based on the information provided in the extracts: python class Items(HttpStream): url_base = "FOO_URL" primary_key = "id" def __init__(self, ids: list, **kwargs): super().__init__(**kwargs) self.ids = ids def path(self, **kwargs) -> str: return f"items/{self.ids.pop(0)}" if self.ids else None def parse_response(self, response: requests.Response, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None,) -> Iterable[Mapping]: if response.status_code == 200: return [response.json()] elif response.status_code == 404: return [] In this example, the Items class takes a list of IDs as an argument. The path method uses these IDs to generate the path for the API call. If there are no more IDs left in the list, it returns None, which should prevent further API calls. Please note that this is a simplified example and you might need to adjust it according to your specific use case and the API you're working with. For more detailed information, you can refer to the [Airbyte documentation](https://docs.airbyte.com/connector-development/cdk-python/http-streams).