Skip to content

Commit c3a15fe

Browse files
authored
feat: Add Portfolio API and update build process to allow multi-file OpenAPI specs (#69)
* feat: migrate portfolio API spec * refactor: move referenced schemas into portfolio API from deprecated external files * refactor: move open api yaml into their own folder * feat: update build script to accommodate new file structure for openAPI specs * fix: remove unused components from portolio api spec * Revert "fix: remove unused components from portolio api spec" This reverts commit 34cb133. * fix: comment out unused components in portfolio API * fix(portfolio-api): move parameters to be in the correct components section * fix(portfolioAPI): add mandatory parameters field * fix(portfolioAPI): update error type definition to allow null values correctly --------- Co-authored-by: dslovinsky <dslovinsky@users.noreply.github.com>
1 parent cb135be commit c3a15fe

File tree

15 files changed

+5842
-24
lines changed

15 files changed

+5842
-24
lines changed

build/api-specs/alchemy/rest/portfolio.json

Lines changed: 4013 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate-open-api.sh

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,37 @@ pids=()
3232
# variable to track if any lint commands fail
3333
lint_failed=0
3434

35-
for file in src/openapi/*; do
36-
if [ -f "$file" ]; then
37-
filename="build/api-specs/alchemy/rest/$(basename "$file" .yaml).json"
38-
(
39-
if [ "$validate_only" = true ]; then
40-
# Only run lint when validate-only is true
41-
if ! pnpm exec redocly lint "$file" --format json; then
42-
exit 1
43-
fi
44-
else
45-
# Run both bundle and lint when validate-only is false
46-
if ! pnpm exec redocly bundle "$file" --dereferenced --output "$filename" --ext json --remove-unused-components; then
47-
exit 1
48-
fi
49-
# Add warning message to the JSON file
50-
jq '{"x-generated-warning": "⚠️ This file is auto-generated. Do not edit manually"} + .' "$filename" > "$filename.tmp" && mv "$filename.tmp" "$filename" || exit 1
51-
if ! pnpm exec redocly lint "$filename" --format json; then
52-
exit 1
53-
fi
54-
fi
55-
) &
35+
# Process only the main YAML file in each subdirectory
36+
for dir in src/openapi/*/; do
37+
if [ -d "$dir" ]; then
38+
# Get the main YAML file (same name as directory)
39+
dirname=$(basename "$dir")
40+
file="$dir${dirname}.yaml"
5641

57-
# Store the PID of the background process
58-
pids+=($!)
42+
if [ -f "$file" ]; then
43+
filename="build/api-specs/alchemy/rest/${dirname}.json"
44+
(
45+
if [ "$validate_only" = true ]; then
46+
# Only run lint when validate-only is true
47+
if ! pnpm exec redocly lint "$file" --format json; then
48+
exit 1
49+
fi
50+
else
51+
# Run both bundle and lint when validate-only is false
52+
if ! pnpm exec redocly bundle "$file" --dereferenced --output "$filename" --ext json --remove-unused-components; then
53+
exit 1
54+
fi
55+
# Add warning message to the JSON file
56+
jq '{"x-generated-warning": "⚠️ This file is auto-generated. Do not edit manually"} + .' "$filename" > "$filename.tmp" && mv "$filename.tmp" "$filename" || exit 1
57+
if ! pnpm exec redocly lint "$filename" --format json; then
58+
exit 1
59+
fi
60+
fi
61+
) &
62+
63+
# Store the PID of the background process
64+
pids+=($!)
65+
fi
5966
fi
6067
done
6168

File renamed without changes.
File renamed without changes.

src/openapi/nft.yaml renamed to src/openapi/nft/nft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ paths:
10551055
"/v3/{apiKey}/refreshNftMetadata":
10561056
post:
10571057
summary: Refresh NFT Metadata
1058-
description: |
1058+
description: |
10591059
Submits a request for Alchemy to refresh the cached metadata of a specific NFT token.
10601060
10611061
<Note>Please note that this endpoint is only supported on Ethereum (Mainnet & Sepolia), Polygon (Mainnet, Mumbai & Amoy), Arbitrum One (mainnet), Optimism (mainnet) & Base (mainnet). For other chains, you could use the `getNFTMetadata` endpoint with the `refreshCache` parameter set to `true` to refresh the metadata!</Note>
File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
summary: NFTs By Wallet
2+
description: >
3+
Fetches NFTs for multiple wallet addresses and networks. Returns a list of NFTs and metadata for each wallet/network combination. This endpoint is supported on Ethereum and many L2s, including Polygon, Arbitrum, Optimism, Base, World Chain and more. See the full list of supported networks [here](https://dashboard.alchemy.com/chains?service=token-api&utm_source=readme&utm_medium=link&utm_campaign=docs_method_chains_link_v1_tokens).
4+
tags: ["📚 Portfolio APIs"]
5+
x-readme:
6+
samples-languages:
7+
- javascript
8+
- curl
9+
- python
10+
- go
11+
parameters:
12+
- $ref: "./../../portfolio.yaml#/components/parameters/apiKey"
13+
requestBody:
14+
required: true
15+
content:
16+
application/json:
17+
schema:
18+
$ref: "./../../portfolio.yaml#/components/schemas/ByAddressRequestWithNFTOptionsAndPaging"
19+
responses:
20+
"200":
21+
description: Successful response!
22+
content:
23+
application/json:
24+
schema:
25+
$ref: "./../../portfolio.yaml#/components/schemas/NFTByOwnerResponse"
26+
"400":
27+
description: "Bad Request: Invalid input (e.g., malformed JSON)."
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "./../../portfolio.yaml#/components/schemas/ErrorResponse"
32+
"429":
33+
description: "Too Many Requests: Rate limit exceeded."
34+
content:
35+
application/json:
36+
schema:
37+
$ref: "./../../portfolio.yaml#/components/schemas/ErrorResponse"
38+
operationId: get-nfts-by-address
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
summary: NFT Collections By Wallet
2+
description: >
3+
Fetches NFT collections (contracts) for multiple wallet addresses and networks. Returns a list of collections and metadata for each wallet/network combination. This endpoint is supported on Ethereum and many L2s, including Polygon, Arbitrum, Optimism, Base, World Chain and more. See the full list of supported networks [here](https://dashboard.alchemy.com/chains?service=token-api&utm_source=readme&utm_medium=link&utm_campaign=docs_method_chains_link_v1_tokens).
4+
tags: ["📚 Portfolio APIs"]
5+
x-readme:
6+
samples-languages:
7+
- javascript
8+
- curl
9+
- python
10+
- go
11+
parameters:
12+
- $ref: "./../../../portfolio.yaml#/components/parameters/apiKey"
13+
requestBody:
14+
required: true
15+
content:
16+
application/json:
17+
schema:
18+
$ref: "./../../../portfolio.yaml#/components/schemas/ByAddressRequestWithNFTOptions"
19+
responses:
20+
"200":
21+
description: Successful response!
22+
content:
23+
application/json:
24+
schema:
25+
$ref: "./../../../portfolio.yaml#/components/schemas/NFTByOwnerResponse"
26+
"400":
27+
description: "Bad Request: Invalid input (e.g., malformed JSON)."
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "./../../../portfolio.yaml#/components/schemas/ErrorResponse"
32+
"429":
33+
description: "Too Many Requests: Rate limit exceeded."
34+
content:
35+
application/json:
36+
schema:
37+
$ref: "./../../../portfolio.yaml#/components/schemas/ErrorResponse"
38+
operationId: get-nft-contracts-by-address
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
summary: Token Balances By Wallet
2+
description: >
3+
Fetches fungible tokens (native and ERC-20) for multiple wallet addresses and networks. Returns a list of tokens with balances for each wallet/network combination. This endpoint is supported on Ethereum, Solana, and 30+ EVM chains. See the full list of supported networks [here](https://dashboard.alchemy.com/chains?service=token-api&utm_source=readme&utm_medium=link&utm_campaign=docs_method_chains_link_v1_tokens)
4+
tags: ["📚 Portfolio APIs"]
5+
x-readme:
6+
samples-languages:
7+
- javascript
8+
- curl
9+
- python
10+
- go
11+
parameters:
12+
- $ref: "./../../../portfolio.yaml#/components/parameters/apiKey"
13+
requestBody:
14+
required: true
15+
content:
16+
application/json:
17+
schema:
18+
$ref: "./../../../portfolio.yaml#/components/schemas/ByAddressRequestWith3PairsAnd20Networks"
19+
responses:
20+
"200":
21+
description: Successful response!
22+
content:
23+
application/json:
24+
schema:
25+
$ref: "./../../../portfolio.yaml#/components/schemas/TokenBalancesResponse"
26+
"400":
27+
description: "Bad Request: Invalid input (e.g., malformed JSON)."
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "./../../../portfolio.yaml#/components/schemas/ErrorResponse"
32+
"429":
33+
description: "Too Many Requests: Rate limit exceeded."
34+
content:
35+
application/json:
36+
schema:
37+
$ref: "./../../../portfolio.yaml#/components/schemas/ErrorResponse"
38+
operationId: get-token-balances-by-address
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
summary: Tokens By Wallet
2+
description: >
3+
Fetches fungible tokens (native and ERC-20) for multiple wallet addresses and networks. Returns a list of tokens with balances, prices, and metadata for each wallet/network combination. This endpoint is supported on Ethereum, Solana, and 30+ EVM chains. See the full list of supported networks [here](https://dashboard.alchemy.com/chains?service=token-api&utm_source=readme&utm_medium=link&utm_campaign=docs_method_chains_link_v1_tokens).
4+
tags: ["📚 Portfolio APIs"]
5+
x-readme:
6+
samples-languages:
7+
- javascript
8+
- curl
9+
- python
10+
- go
11+
parameters:
12+
- $ref: "./../../portfolio.yaml#/components/parameters/apiKey"
13+
requestBody:
14+
required: true
15+
content:
16+
application/json:
17+
schema:
18+
$ref: "./../../portfolio.yaml#/components/schemas/ByAddressRequestWithOptions"
19+
responses:
20+
"200":
21+
description: Successful response!
22+
content:
23+
application/json:
24+
schema:
25+
$ref: "./../../portfolio.yaml#/components/schemas/TokensResponse"
26+
"400":
27+
description: "Bad Request: Invalid input (e.g., malformed JSON)."
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "./../../portfolio.yaml#/components/schemas/ErrorResponse"
32+
"429":
33+
description: "Too Many Requests: Rate limit exceeded."
34+
content:
35+
application/json:
36+
schema:
37+
$ref: "./../../portfolio.yaml#/components/schemas/ErrorResponse"
38+
operationId: get-tokens-by-address

0 commit comments

Comments
 (0)