# Importing an API Source

To create an API store, you need to first connect your APIs to [API.market](https://api.market/).

When a user calls API.market, then API.market will call your APIs using the defined API Source and the configuration.

### 🎯 Overview

The API Source is the OpenAPI specification that connects your APIs to API.market. API.market acts as an API gateway, making your API available through a unified platform.

{% hint style="info" %}
💡 **How it works:** API.market proxies requests to your API using the OpenAPI specification. This allows API.market to handle authentication, billing, analytics, and rate limiting automatically.
{% endhint %}

### 📋 Prerequisites

Before you begin, you'll need:

✅ An OpenAPI specification file (YAML or JSON)\
✅ Your API's base URL\
✅ Authentication details (if required)

{% hint style="warning" %}
⚠️ **Don't have an OpenAPI spec yet?** You can create one using ChatGPT. Follow our guide: [Create OpenAPI spec using ChatGPT](https://docs.api.market/fundamentals/create-openapi-spec-using-chatgpt)
{% endhint %}

### 🚀 Step-by-Step Guide

**1. Click on "OpenAPI Specs" on the left side menu under "Manage APIs".**

Navigate to the Seller Console and select your organization from the dropdown. Then click on **"Manage APIs"** in the left sidebar and select **"OpenAPI Specs"** .<br>

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2FOSdSHHSGaSmwR1BtBjSE%2Fimage.png?alt=media&#x26;token=664c0dfd-6cfd-42c6-938d-dcd3a37642eb" alt=""><figcaption></figcaption></figure>

**2. Click on the "Import API Source" button.**

This wizard will pop up:<br>

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2FmyE5JSmkGFUDqLbSo0B0%2Fimage.png?alt=media&#x26;token=71c9887c-7c7b-4972-a5e4-cc4ae712d9b4" alt=""><figcaption></figcaption></figure>

Click **"Continue"** to proceed after selecting **"Yes, I have an OpenAPI schema"**.

{% hint style="info" %}
💡 **For now, we only support creating an API Source using an OpenAPI schema.**

Need help? Check out this [example OpenAPI schema](https://example.com/openapi-example).
{% endhint %}

***

**3. Import the OpenAPI YAML or JSON file.**

Upload or drag and drop your OpenAPI specification file. You should be able to see the paths imported from the YAML file.

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2F3m91ExbwIKc1AYkUDQYT%2Fimage.png?alt=media&#x26;token=7580a26f-ad37-40ff-8eaa-e7fc4474ea85" alt=""><figcaption></figcaption></figure>

#### Step 4: Configure Custom Headers

After importing your OpenAPI file, proceed to **Step 3: Configure API Headers**. Here you can add custom headers that will be included in every API request to your backend.

1. Enter a JSON object in the text area
2. Format: `{"Header-Name": "header-value"}`
3. Example:

   ```json
   {
     "Content-Type": "application/json",
     "Accept": "application/json",
     "X-Custom-Header": "custom-value"
   }
   ```

**Note:** If you don't need custom headers, you can leave this as `{}` (empty JSON object) and proceed.<br>

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2FOV6iRWSfR5FiNKetTshe%2Fimage.png?alt=media&#x26;token=183f342e-1441-453c-968b-197f6491f326" alt=""><figcaption></figcaption></figure>

#### Step 5: Configure Base Path URL

Click "Continue" to proceed , here you'll set the base URL for all API requests.

1. The Base URL field may be pre-filled if detected from your OpenAPI spec's `servers` section
2. Review or enter your API's base URL
3. Format: `https://api.example.com/v1`
4. This URL will be used as the base for all API requests

**Example:**

```
https://api.example.com/v1
```

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2Fl07Z40PiFtdwo3CFBvLT%2Fimage.png?alt=media&#x26;token=6a52a7ce-e650-4176-9c5f-46346eaa1160" alt=""><figcaption></figcaption></figure>

#### Step 6: Configure Authentication

Click "Continue" to proceed . Here you'll choose how your API authenticates requests. This is the endpoint API.market backend will call.

You have five authentication options:

**Option 1: No Authentication**

* Select the "None" tab
* No authentication will be used when making API requests
* Use this if your API doesn't require authentication

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2FA1Yz7OntHAvxyHUWP9iC%2Fimage.png?alt=media&#x26;token=5bfc38da-3080-4c49-9349-4b7852c1779d" alt=""><figcaption></figcaption></figure>

**Option 2: API Key Authentication**

* Select the "API Key" tab
* Enter the **Header Name** (e.g., `X-API-Key`, `Authorization`)
* Enter the **API Key Value** (this will be masked for security)
* The API key will be sent in the specified header with each request

**Example:**

* Header Name: `X-API-Key`
* API Key Value: `your-secret-api-key`

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2FRQFPlmHf2v0EWt3pWNYh%2Fimage.png?alt=media&#x26;token=9667ebb8-684a-4c11-9543-b731878879f8" alt=""><figcaption></figcaption></figure>

**Option 3: Bearer Token Authentication**

* Select the "Bearer Token" tab
* Enter your bearer token (this will be masked for security)
* The token will be sent in the `Authorization` header as `Bearer <token>`

**Example:**

* Token: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...`

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2FUrr34WZ42z73agjhKaTA%2Fimage.png?alt=media&#x26;token=9cc3edd9-58d9-4195-9128-9c3ede34e18c" alt=""><figcaption></figcaption></figure>

**Option 4: Basic Authentication**

* Select the "Basic Auth" tab
* Enter your **Username**
* Enter your **Password** (this will be masked for security)
* Credentials will be base64 encoded and sent in the `Authorization` header

**Example:**

* Username: `myuser`
* Password: `mypassword`

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2Fob1WEtDpXXmco7HeN4ez%2Fimage.png?alt=media&#x26;token=7a60d6dd-aa66-4943-9b48-8fd46a177e4a" alt=""><figcaption></figcaption></figure>

**Option 5: Query Parameter Authentication**

* Select the "Query Param" tab
* Enter the **Parameter Key** (e.g., `api_key`, `token`)
* Enter the **Parameter Value** (this will be masked for security)
* The parameter will be added to the query string of each request

**Example:**

* Param Key: `api_key`
* Param Value: `your-api-key-value`

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2F7QBHq4difHSHi5Hno4Ky%2Fimage.png?alt=media&#x26;token=32f87a76-4e51-40a4-9770-82c8db387968" alt=""><figcaption></figcaption></figure>

#### Step 7: Review Summary and Create

Click "Continue" to proceed .Here you'll review all your configuration before creating the API Source.

The summary will show:

* **API Source Name** - The detected or entered name
* **API Version** - The detected version
* **Base URL** - The configured base URL
* **Custom Headers** - The JSON object of custom headers
* **Authentication** - The selected authentication method and configuration
* **Endpoints** - List of all detected endpoints

<figure><img src="https://979396929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJpzXHBiEL3zWqYljGVxS%2Fuploads%2FxJfULP4yGGOqSokraRe4%2Fimage.png?alt=media&#x26;token=54aa3eee-a6b7-4b32-942e-86bc0e9adc27" alt=""><figcaption></figcaption></figure>

**Review checklist:**

* ✅ API Name and Version are correct
* ✅ Base URL is correct
* ✅ Custom Headers are properly formatted
* ✅ Authentication is configured correctly
* ✅ All expected endpoints are listed

1. Review the summary carefully to ensure all details are correct
2. Click "Create API Source" or "Finish" button
3. Your API Source will be created and you'll be redirected to the API Sources list
4. You should see your new API Source in the list

**Success!** Your API Source is now ready to be used when creating products.

***

### What's Next?

After importing your API Source, you can:

1. **Create Products** - Use your API Source to create API products
2. **Configure Pricing Plans** - Set up pricing for your API endpoints
3. **Test Your APIs** - Use the API Playground to test your endpoints
4. **View Analytics** - Monitor usage and performance

***

### Troubleshooting

#### Common Issues

**Issue: "No endpoints found"**

* **Solution:** Check that your OpenAPI spec has a `paths` object with at least one endpoint defined

**Issue: "Invalid JSON/YAML"**

* **Solution:** Validate your OpenAPI spec using an online validator like [Swagger Editor](https://editor.swagger.io/)

**Issue: "Base URL not detected"**

* **Solution:** Make sure your OpenAPI spec includes a `servers` array with at least one server URL, or manually enter it in Step 6

**Issue: "Authentication not working"**

* **Solution:**
  * Verify your authentication credentials are correct
  * Check that the header name matches what your API expects
  * Ensure the authentication type matches your API's requirements

***

### Best Practices

1. **Validate Your OpenAPI Spec** - Use tools like Swagger Editor to validate your spec before importing
2. **Test Authentication** - After creating your API Source, test it with a sample request to ensure authentication works
3. **Use Descriptive Names** - Choose clear API Source names that help you identify them later
4. **Document Custom Headers** - Keep track of what custom headers you're using and why
5. **Version Your APIs** - Use semantic versioning in your API version field (e.g., `1.0.0`, `2.1.3`)

***
