1
0
mirror of synced 2025-12-21 11:01:41 -05:00
Files
airbyte/docs/connector-development/tutorials/cdk-tutorial-python-http/3-define-inputs.md
Pedro S. Lopez 0c12ad9136 python generators output spec.yaml files (#12245)
* generators output spec.yaml files

* source-singer generator also uses spec.yaml

* update scaffold

* update python cdk tutorials to use spec.yaml

* add docs updates

* consistency
2022-04-26 07:16:04 -07:00

2.2 KiB

Step 3: Define Inputs

Each connector declares the inputs it needs to read data from the underlying data source. This is the Airbyte Protocol's spec operation.

The simplest way to implement this is by creating a spec.yaml file in source_<name>/spec.yaml which describes your connector's inputs according to the ConnectorSpecification schema. This is a good place to start when developing your source. Using JsonSchema, define what the inputs are (e.g. username and password). Here's an example of what the spec.yaml looks like for the Stripe API source.

For more details on what the spec is, you can read about the Airbyte Protocol here.

The generated code that Airbyte provides, handles implementing the spec method for you. It assumes that there will be a file called spec.yaml in the same directory as source.py. If you have declared the necessary JsonSchema in spec.yaml you should be done with this step.

Given that we'll pulling currency data for our example source, we'll define the following spec.yaml:

documentationUrl: https://docs.airbyte.io/integrations/sources/exchangeratesapi
connectionSpecification:
  $schema: http://json-schema.org/draft-07/schema#
  title: Python Http Tutorial Spec
  type: object
  required:
    - start_date
    - base
  additionalProperties: false
  properties:
    start_date:
      type: string
      description: Start getting data from that date.
      pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}$
      examples:
        - "%Y-%m-%d"
    base:
      type: string
      examples:
        - USD
        - EUR
      description: "ISO reference currency. See <a href=\"https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html\">here</a>."

In addition to metadata, we define two inputs:

  • start_date: The beginning date to start tracking currency exchange rates from
  • base: The currency whose rates we're interested in tracking