Configuring OpenAPI Source for API Key in Header or Query Param

Original Slack Thread

I am trying to use openapi but the api i want to connect to only supports giving an api key via header or query param

Hey there! :wave:

<@U06TM7M40RK> Can you help with the questions in this thread?

:information_source: Please continue to tag RunLLM (e.g <@U06TM7M40RK>) to have it continue generating responses!

To connect to an API using OpenAPI in DataHub, where the API requires an API key to be passed via a header or query parameter, you can configure the OpenAPI source to include the necessary authentication details.

  1. API Key in Header: You can configure the OpenAPI source to include the API key in the request headers. This is typically done by specifying the bearer_token or similar configuration in your OpenAPI ingestion recipe. According to the <OpenAPI | DataHub capabilities documentation>, you can use a bearer token for authentication, which is included in the headers.

  2. API Key in Query Parameter: If the API key needs to be included as a query parameter, you might need to modify the URL in the OpenAPI configuration to append the API key as a query parameter.

Here’s an example of how you might configure the OpenAPI source with a bearer token:

source:
  type: openapi
  config:
    name: "example-api"
    url: "https://api.example.com"
    swagger_file: "/path/to/swagger.yaml"
    bearer_token: "<your-api-key>"

If you need to pass the API key as a query parameter, you might adjust the url field to include the API key, like so:

url: "https://api.example.com?api_key=<your-api-key>"

Would you like more detailed guidance on setting up the OpenAPI source in DataHub?

Sources:

  • <OpenAPI | DataHub capabilities documentation> :+1: 0 button :-1: 0 button :bulb: Hint: Mention @runllm in the thread for followups.

Hi :slight_smile: ! Did this interaction resolve your issue or do you still require assistance ?

Please tag @ RunLLM if you still need further assistance !

Or tag @Datahub Community Support if you require a person to take a look :slight_smile:

Hope this helps ! ><