03 - Fetching Data
Continuing from the previous section, we will look at fetching data from another endpoint whilst utilizing input parameters to target something specific.
We will utilize:
- variable substitutions to dynamically adjust the configuration.
 httpfunctionality to fetch the data, complete options here.
Steps
1. HTTP GET API
In this simple example we will be creating a HTTP GET API where we will call another API endpoint and use a query parameter to specify an id parameter to fetch a specific comment.
Deploy via Hosted / Managed
- Ensure you are logged into https://app.airpipe.io
 - Click Deploy
to load the below example config into your account
- Alternatively, go to Configurations > Add New, and copy and paste the example
 
 
Deploy via Self Hosted / Unmanaged
- A 
configsdirectory should have been created automatically for you, else create one. - Copy the below example config into your 
configsdirectory, eg.configs/03-http-get-data.yml - Stop/Start 
airpipeeg../airpipe server --api-key your-api-key --config-dir configs 
Example Config
Deployloading...
Test
Hosted mode, either navigate to or curl:
- 
The load configuration UI will automatically show you what your detected routes are, you can copy this for the next steps.
 - 
The link is automatically built with your organization uuid and environment, your API endpoints can be found here if required https://app.airpipe.io/configurations.
 - 
Update the route as necessary
 
curl https://app.airpipe.io/your_org_uuid/staging/tutorial/getdata
Self hosted mode, either navigate to or curl:
http://0.0.0.0:4111/tutorial/getdata
curl http://0.0.0.0:4111/tutorial/getdata
Response
{
  "data": {
    "GetData": {
      "data": {
        "body": {
          "body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium",
          "email": "Eliseo@gardner.biz",
          "id": 1,
          "name": "id labore ex et quam laborum",
          "postId": 1
        },
        "headers": {
          "accept-ranges": "bytes",
          "access-control-allow-credentials": "true",
          "age": "15421",
          "alt-svc": "h3=\":443\"; ma=86400",
          "cache-control": "max-age=43200",
          "cf-cache-status": "HIT",
          "cf-ray": "883a2d826dad8197-IAD",
          "content-length": "268",
          "content-type": "application/json; charset=utf-8",
          "date": "Tue, 14 May 2024 10:24:18 GMT",
          "etag": "W/\"10c-KJ4I9RM/+33TKdV8CFsIvqsDSP0\"",
          "expires": "-1",
          "nel": "{\"report_to\":\"heroku-nel\",\"max_age\":3600,\"success_fraction\":0.005,\"failure_fraction\":0.05,\"response_headers\":[\"Via\"]}",
          "pragma": "no-cache",
          "report-to": "{\"group\":\"heroku-nel\",\"max_age\":3600,\"endpoints\":[{\"url\":\"https://nel.heroku.com/reports?ts=1715432434&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=unAGx%2FNj2kC7aw%2BJo6jqZ5aN559MvyKIxP1xTVZgHcw%3D\"}]}",
          "reporting-endpoints": "heroku-nel=https://nel.heroku.com/reports?ts=1715432434&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=unAGx%2FNj2kC7aw%2BJo6jqZ5aN559MvyKIxP1xTVZgHcw%3D",
          "server": "cloudflare",
          "vary": "Origin, Accept-Encoding",
          "via": "1.1 vegur",
          "x-content-type-options": "nosniff",
          "x-powered-by": "Express",
          "x-ratelimit-limit": "1000",
          "x-ratelimit-remaining": "999",
          "x-ratelimit-reset": "1715432467"
        },
        "status": 200
      },
      "time.ms": 10
    }
  }
}
2. HTTP POST API (Webhook)
In this simple example we will be creating a HTTP POST API where we will call another API endpoint and use a value in the body to specify an id parameter to fetch a specific comment.
Deploy via Hosted / Managed
- Ensure you are logged into https://app.airpipe.io
 - Click Deploy
to load the below example config into your account
- Alternatively, go to Configurations > Add New, and copy and paste the example
 
 
Deploy via Self Hosted / Unmanaged
- A 
configsdirectory should have been created automatically for you, else create one. - Copy the below example config into your 
configsdirectory, eg.configs/03-http-post-data.yml - Stop/Start 
airpipeeg../airpipe server --api-key your-api-key --config-dir configs 
Example Config
Deployloading...
Test
Hosted mode, curl or use your preferred API testing tool:
- 
The load configuration UI will automatically show you what your detected routes are, you can copy this for the next steps.
 - 
The link is automatically built with your organization uuid and environment, your API endpoints can be found here if required https://app.airpipe.io/configurations.
 - 
Update the route as necessary
 
curl --location 'https://api.airpipe.io/your-org-uuid/staging/tutorial/getdata' \
--header 'Content-Type: application/json' \
--data '{
    "id": 1
}'
Self hosted mode, curl or use your preferred API testing tool:
curl --location 'http://0.0.0.0:4111/tutorial/getdata' \
--header 'Content-Type: application/json' \
--data '{
    "id": 1
}'
Response
{
  "data": {
    "GetData": {
      "data": {
        "body": {
          "body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium",
          "email": "Eliseo@gardner.biz",
          "id": 1,
          "name": "id labore ex et quam laborum",
          "postId": 1
        },
        "headers": {
          "accept-ranges": "bytes",
          "access-control-allow-credentials": "true",
          "age": "15421",
          "alt-svc": "h3=\":443\"; ma=86400",
          "cache-control": "max-age=43200",
          "cf-cache-status": "HIT",
          "cf-ray": "883a2d826dad8197-IAD",
          "content-length": "268",
          "content-type": "application/json; charset=utf-8",
          "date": "Tue, 14 May 2024 10:24:18 GMT",
          "etag": "W/\"10c-KJ4I9RM/+33TKdV8CFsIvqsDSP0\"",
          "expires": "-1",
          "nel": "{\"report_to\":\"heroku-nel\",\"max_age\":3600,\"success_fraction\":0.005,\"failure_fraction\":0.05,\"response_headers\":[\"Via\"]}",
          "pragma": "no-cache",
          "report-to": "{\"group\":\"heroku-nel\",\"max_age\":3600,\"endpoints\":[{\"url\":\"https://nel.heroku.com/reports?ts=1715432434&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=unAGx%2FNj2kC7aw%2BJo6jqZ5aN559MvyKIxP1xTVZgHcw%3D\"}]}",
          "reporting-endpoints": "heroku-nel=https://nel.heroku.com/reports?ts=1715432434&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=unAGx%2FNj2kC7aw%2BJo6jqZ5aN559MvyKIxP1xTVZgHcw%3D",
          "server": "cloudflare",
          "vary": "Origin, Accept-Encoding",
          "via": "1.1 vegur",
          "x-content-type-options": "nosniff",
          "x-powered-by": "Express",
          "x-ratelimit-limit": "1000",
          "x-ratelimit-remaining": "999",
          "x-ratelimit-reset": "1715432467"
        },
        "status": 200
      },
      "time.ms": 5
    }
  }
}