Skip to content

Commit 4376b31

Browse files
authored
Refresh generic-api readme (#4702)
1 parent 4a15a63 commit 4376b31

5 files changed

Lines changed: 132 additions & 16 deletions

File tree

.changeset/open-boxes-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/ea-scripts': patch
3+
---
4+
5+
Update readme

packages/scripts/src/generate-readme/readmeBlacklist.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"crypto-volatility-index",
1212
"dlc-btc-por",
1313
"dydx-stark",
14-
"generic-api",
1514
"graphql",
1615
"harmony",
1716
"historical-average",
Lines changed: 91 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,77 @@
11
# GENERIC_API
22

3-
![0.0.0](https://img.shields.io/github/package-json/v/smartcontractkit/external-adapters-js?filename=packages/sources/generic-api/package.json) ![v3](https://img.shields.io/badge/framework%20version-v3-blueviolet)
3+
![1.2.0](https://img.shields.io/github/package-json/v/smartcontractkit/external-adapters-js?filename=packages/sources/generic-api/package.json) ![v3](https://img.shields.io/badge/framework%20version-v3-blueviolet)
44

5-
This document maintained manually.
5+
This document was generated automatically. Please see [README Generator](../../scripts#readme-generator) for more info.
66

77
## Variable env vars
88

99
To support a specific value for input parameter `apiName`, the environment variable `<API_NAME>_API_URL`, and optionally `<API_NAME>_AUTH_HEADER` and `<API_NAME>_AUTH_HEADER_VALUE` must be set, where `<API_NAME>` is the upper-snake-case version of the value provided for the `apiName` parameter.
1010

11-
## Environment Variables
11+
## Custom Environment Variables
1212

1313
| Required? | Name | Description | Type |
1414
| :-------: | :---------------------------: | :---------------------------------------------------: | :----: |
1515
|| {API_NAME}\_API_URL | The API URL to use for a given `apiUrl`. | string |
1616
| | {API_NAME}\_AUTH_HEADER | The header to pass the authentication credentials on. | string |
1717
| | {API_NAME}\_AUTH_HEADER_VALUE | The credentials to pass on the authentication header. | string |
1818

19+
## Rate Limiter
20+
21+
| Feeds | Effective refresh interval |
22+
| -------- | ------------------------------------------------ |
23+
| 1 feed | ~1 request every 3 seconds |
24+
| 20 feeds | ~1 request per minute (all feeds share the pool) |
25+
26+
Adjust the limit based on how many feeds run on this EA and how often your data provider (DP) should be called.
27+
28+
### Overriding the default
29+
30+
You can override the built-in limit with these environment variables (they take precedence over the adapter’s default tier):
31+
32+
| Variable | Description |
33+
| ---------------------------- | ----------------------------------------- |
34+
| `RATE_LIMIT_CAPACITY_MINUTE` | Max requests per minute (overrides tier). |
35+
| `RATE_LIMIT_CAPACITY_SECOND` | Max requests per second (overrides tier). |
36+
37+
**Example:** You run 20 feeds and want each feed to refresh about every 5 seconds. That’s 20 × 12 = **240 requests per minute**. Set:
38+
39+
```bash
40+
RATE_LIMIT_CAPACITY_MINUTE=240
41+
```
42+
43+
## Environment Variables
44+
45+
There are no environment variables for this adapter.
46+
1947
---
2048

2149
## Data Provider Rate Limits
2250

23-
| Name | Requests/credits per second | Requests/credits per minute | Requests/credits per hour | Note |
24-
| :-----: | :-------------------------: | :-------------------------: | :-----------------------: | :--: |
25-
| default | | 20 | | |
51+
| Name | Requests/credits per second | Requests/credits per minute | Requests/credits per hour | Note |
52+
| :-----: | :-------------------------: | :-------------------------: | :-----------------------: | :-------------------------------------: |
53+
| default | | 20 | | Rate Limiter is shared across all feeds |
2654

2755
---
2856

2957
## Input Parameters
3058

31-
| Required? | Name | Description | Type | Options | Default |
32-
| :-------: | :------: | :-----------------: | :----: | :--------------------: | :-----: |
33-
| | endpoint | The endpoint to use | string | [http](#http-endpoint) | `http` |
59+
| Required? | Name | Description | Type | Options | Default |
60+
| :-------: | :------: | :-----------------: | :----: | :--------------------------------------------------------: | :-----: |
61+
| | endpoint | The endpoint to use | string | [http](#http-endpoint), [multi-http](#multi-http-endpoint) | `http` |
3462

3563
## Http Endpoint
3664

3765
`http` is the only supported name for this endpoint.
3866

3967
### Input Params
4068

41-
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
42-
| :-------: | :------------------: | :-----: | :------------------------------------------------------------------------------------: | :----: | :-----: | :-----: | :--------: | :------------: |
43-
|| apiName | | Used as prefix for environment variables to find API config | string | | | | |
44-
|| dataPath | | The path to the field containing the data to return | string | | | | |
45-
| | ripcordPath | | The path to the ripcord field if expected | string | | | | |
46-
| | ripcordDisabledValue | | The value the ripcord field should have during normal operation, converted to a string | string | | `false` | | |
69+
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
70+
| :-------: | :------------------: | :-----: | :-------------------------------------------------------------------------------------: | :----: | :-----: | :-----: | :--------: | :------------: |
71+
|| apiName | | Used as prefix for environment variables to find API config | string | | | | |
72+
|| dataPath | | The path to the field containing the data to return | string | | | | |
73+
| | ripcordPath | | The path to the ripcord field if expected | string | | | | |
74+
| | ripcordDisabledValue | | If the ripcord field has a different value than this, the adapter will return an error. | string | | `false` | | |
4775

4876
### Example
4977

@@ -63,4 +91,52 @@ Request:
6391

6492
---
6593

94+
## Multi-http Endpoint
95+
96+
`multi-http` is the only supported name for this endpoint.
97+
98+
### Input Params
99+
100+
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
101+
| :-------: | :-----------------------: | :-----: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------: | :-----: | :-----: | :--------: | :------------: |
102+
|| apiName | | Used as prefix for environment variables to find API config | string | | | | |
103+
|| dataPaths | | Array of data paths to extract from the API response | object[] | | | | |
104+
|| dataPaths.name | | Name of the field in the output response | string | | | | |
105+
|| dataPaths.path | | JSON path to extract from API response | string | | | | |
106+
| | ripcordPath | | The path to the ripcord field if expected | string | | | | |
107+
| | ripcordDisabledValue | | If the ripcord field has a different value than this, the adapter will return an error. | string | | `false` | | |
108+
| | providerIndicatedTimePath | | JSON path to extract the timestamp from the API response. Supports ISO 8601 datetime strings (e.g., "2026-01-19T06:56:22.194Z") or Unix milliseconds (number). The value will be placed in timestamps.providerIndicatedTimeUnixMs. | string | | | | |
109+
110+
### Example
111+
112+
Request:
113+
114+
```json
115+
{
116+
"data": {
117+
"endpoint": "multi-http",
118+
"apiName": "NX8",
119+
"dataPaths": [
120+
{
121+
"name": "result",
122+
"path": "net_asset_value"
123+
},
124+
{
125+
"name": "nav",
126+
"path": "net_asset_value"
127+
},
128+
{
129+
"name": "aum",
130+
"path": "asset_under_management"
131+
}
132+
],
133+
"ripcordPath": "ripcord",
134+
"ripcordDisabledValue": "false",
135+
"providerIndicatedTimePath": "updatedAt"
136+
}
137+
}
138+
```
139+
140+
---
141+
66142
MIT License
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## Variable env vars
2+
3+
To support a specific value for input parameter `apiName`, the environment variable `<API_NAME>_API_URL`, and optionally `<API_NAME>_AUTH_HEADER` and `<API_NAME>_AUTH_HEADER_VALUE` must be set, where `<API_NAME>` is the upper-snake-case version of the value provided for the `apiName` parameter.
4+
5+
## Custom Environment Variables
6+
7+
| Required? | Name | Description | Type |
8+
| :-------: | :---------------------------: | :---------------------------------------------------: | :----: |
9+
|| {API_NAME}\_API_URL | The API URL to use for a given `apiUrl`. | string |
10+
| | {API_NAME}\_AUTH_HEADER | The header to pass the authentication credentials on. | string |
11+
| | {API_NAME}\_AUTH_HEADER_VALUE | The credentials to pass on the authentication header. | string |
12+
13+
## Rate Limiter
14+
15+
| Feeds | Effective refresh interval |
16+
| -------- | ------------------------------------------------ |
17+
| 1 feed | ~1 request every 3 seconds |
18+
| 20 feeds | ~1 request per minute (all feeds share the pool) |
19+
20+
Adjust the limit based on how many feeds run on this EA and how often your data provider (DP) should be called.
21+
22+
### Overriding the default
23+
24+
You can override the built-in limit with these environment variables (they take precedence over the adapter’s default tier):
25+
26+
| Variable | Description |
27+
| ---------------------------- | ----------------------------------------- |
28+
| `RATE_LIMIT_CAPACITY_MINUTE` | Max requests per minute (overrides tier). |
29+
| `RATE_LIMIT_CAPACITY_SECOND` | Max requests per second (overrides tier). |
30+
31+
**Example:** You run 20 feeds and want each feed to refresh about every 5 seconds. That’s 20 × 12 = **240 requests per minute**. Set:
32+
33+
```bash
34+
RATE_LIMIT_CAPACITY_MINUTE=240
35+
```

packages/sources/generic-api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const adapter = new Adapter({
1212
tiers: {
1313
default: {
1414
rateLimit1m: 20,
15+
note: 'Rate Limiter is shared across all feeds',
1516
},
1617
},
1718
},

0 commit comments

Comments
 (0)