Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/blockapi-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python 3.9
- name: Set up Python 3.12.11
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.12.11'

- name: Verify Python
run: python --version

- name: Restore cache
uses: actions/cache@v3
Expand Down
16 changes: 2 additions & 14 deletions blockapi/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
from datetime import datetime
from time import sleep

import cfscrape
import requests

import blockapi

cfscrape.DEFAULT_CIPHERS += ':!SHA'


class Service(ABC):
"""General class for handling blockchain API services."""
Expand All @@ -34,13 +31,7 @@ def build_request_url(self, request_method, **params):
return self.base_url

def request(
self,
request_method,
with_rate_limit=False,
with_cloudflare=False,
body=None,
headers=None,
**params
self, request_method, with_rate_limit=False, body=None, headers=None, **params
):
request_url = self.build_request_url(request_method, **params)

Expand All @@ -53,10 +44,7 @@ def request(
if not headers:
headers = {}

if with_cloudflare:
reqobj = cfscrape.create_scraper()
else:
reqobj = requests
reqobj = requests

if with_rate_limit and self.rate_limit:
self.wait_for_next_request()
Expand Down
186 changes: 186 additions & 0 deletions blockapi/test/v2/api/cassettes/test_dissable_mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Referer:
- https://www.mintscan.io/
User-Agent:
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/50.0.2661.102 Safari/537.36
method: GET
uri: https://lcd-dydx.cosmostation.io/cosmos/bank/v1beta1/balances/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh
response:
body:
string: '{"balances":[{"denom":"adydx","amount":"8342195962385344539"}],"pagination":{"next_key":null,"total":"1"}}'
headers:
Access-Control-Allow-Headers:
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
Access-Control-Allow-Methods:
- GET, POST, OPTIONS
Access-Control-Expose-Headers:
- Content-Length,Content-Range
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
Date:
- Thu, 28 Aug 2025 13:12:14 GMT
Grpc-Metadata-Content-Type:
- application/grpc+cosmos-sdk-grpc-codec
Grpc-Metadata-X-Cosmos-Block-Height:
- '53991912'
Server:
- nginx
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding
X-Server-Time:
- '1756386734'
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Referer:
- https://www.mintscan.io/
User-Agent:
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/50.0.2661.102 Safari/537.36
method: GET
uri: https://lcd-dydx.cosmostation.io/cosmos/staking/v1beta1/delegations/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh?pagination.limit=1000
response:
body:
string: '{"delegation_responses":[],"pagination":{"next_key":null,"total":"0"}}'
headers:
Access-Control-Allow-Headers:
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
Access-Control-Allow-Methods:
- GET, POST, OPTIONS
Access-Control-Expose-Headers:
- Content-Length,Content-Range
Connection:
- keep-alive
Content-Length:
- '70'
Content-Type:
- application/json
Date:
- Thu, 28 Aug 2025 13:12:15 GMT
Grpc-Metadata-Content-Type:
- application/grpc+cosmos-sdk-grpc-codec
Grpc-Metadata-X-Cosmos-Block-Height:
- '53991912'
Server:
- nginx
X-Server-Time:
- '1756386735'
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Referer:
- https://www.mintscan.io/
User-Agent:
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/50.0.2661.102 Safari/537.36
method: GET
uri: https://lcd-dydx.cosmostation.io/cosmos/staking/v1beta1/delegators/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh/unbonding_delegations
response:
body:
string: '{"unbonding_responses":[],"pagination":{"next_key":null,"total":"0"}}'
headers:
Access-Control-Allow-Headers:
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
Access-Control-Allow-Methods:
- GET, POST, OPTIONS
Access-Control-Expose-Headers:
- Content-Length,Content-Range
Connection:
- keep-alive
Content-Length:
- '69'
Content-Type:
- application/json
Date:
- Thu, 28 Aug 2025 13:12:16 GMT
Grpc-Metadata-Content-Type:
- application/grpc+cosmos-sdk-grpc-codec
Grpc-Metadata-X-Cosmos-Block-Height:
- '53991913'
Server:
- nginx
X-Server-Time:
- '1756386736'
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Referer:
- https://www.mintscan.io/
User-Agent:
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/50.0.2661.102 Safari/537.36
method: GET
uri: https://lcd-dydx.cosmostation.io/cosmos/distribution/v1beta1/delegators/dydx1aff76avnwpnk02wxkc6n5xnwasjkgekarwznsh/rewards
response:
body:
string: '{"rewards":[],"total":[]}'
headers:
Access-Control-Allow-Headers:
- DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
Access-Control-Allow-Methods:
- GET, POST, OPTIONS
Access-Control-Expose-Headers:
- Content-Length,Content-Range
Connection:
- keep-alive
Content-Length:
- '25'
Content-Type:
- application/json
Date:
- Thu, 28 Aug 2025 13:12:16 GMT
Grpc-Metadata-Content-Type:
- application/grpc+cosmos-sdk-grpc-codec
Grpc-Metadata-X-Cosmos-Block-Height:
- '53991914'
Server:
- nginx
X-Server-Time:
- '1756386736'
status:
code: 200
message: OK
version: 1
26 changes: 9 additions & 17 deletions blockapi/test/v2/api/cassettes/test_fetch_metaplex_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,14 @@ interactions:
Content-Type:
- application/json
User-Agent:
- python-requests/2.31.0
- python-requests/2.32.5
method: POST
uri: https://api.mainnet-beta.solana.com/
response:
body:
string: !!binary |
H4sIAAAAAAAEA6pWyirOzysqSFayUjLSM1DSUSpKLS7NKVGyqlZKzs8rSa0AMxMLMsNSi4oz8/OU
rJQM9Qwt9IxMlXSUinPyS5SsjCzNDYwsjU1ManWUyhJzSlNBmlMSSxKVrKKVnLxM87MjgvJKQl1T
y0vdM0sD/T19w0sstCOzy9zyIs31XfLTMwIqq0wLy/3yLcrDC6ryM3KSvQOywj1dnHOM89LT3YtL
jJ1T3cpCtQMMyx3NKv18M3It0h0dHR0Dw/0MPF2z0/0znUIT3UPTA0Oz00M9vMqS3TNyIo2zQUpg
2BvECAz1CwXRYOwLMsIpP8UjqDy5Kr/MxyglI8U9zDgyIrs02T2nNDIiKMMn1684yTgs28copzwq
z7csNNwwPCrbMDDQMCwwuSos3DfcsiQyNMgoyci0wLcqw9jf3c0tOM/JPcy9wC08x8s/NNewLCwv
JyfVLSMiKhBs6+An0kycHEFBM/hdOrxcGGhrq6SjlJRYnGpmohSro5RakZpcWpKYlJOqZJWWmFOc
qqOUk5hbkF9UUqxkZWhqaGhqZmCgo5RfnpdapGSllJtakliYVFERmlqUUmhkkZxlGJTkGJ4dGZhr
XJlUlZVklmiRVGJqaFFhWAzO5IDllbgW5CdnKFkZWpiYmJmbmBiYG5sbWJqaGpoZmuooFRckJqcq
WZkZmNfW6ihlpihZGdZyAQAzXeNRLQQAAA==
string: '{"jsonrpc":"2.0","result":{"context":{"apiVersion":"2.3.6","slot":363077074},"value":{"data":["BJ5okXRntUEewuGiuQOIMWt8+YkvFnY7/DoghPyz5qwNo8wWpzohlcKPjWIDCl3nggGst3CeFvU+P1wA6yNMhm8gAAAAQWN0IEkgOiBUaGUgQUkgUHJvcGhlY3kAAAAAAAAAAAAKAAAAQUNUAAAAAAAAAMgAAABodHRwczovL2dhdGV3YXkucGluYXRhLmNsb3VkL2lwZnMvUW1WZk1QQ1VQczVWMW9tYUR2b25pMzh3OGFFSnBGVGpFWlJOUm1vVnlleFhXZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf4BAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==","base64"],"executable":false,"lamports":5115600,"owner":"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","rentEpoch":18446744073709551615,"space":607}},"id":1}

'
headers:
access-control-allow-headers:
- authorization, *
Expand All @@ -46,7 +38,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Tue, 22 Oct 2024 09:44:34 GMT
- Thu, 28 Aug 2025 13:00:35 GMT
transfer-encoding:
- chunked
vary:
Expand All @@ -62,11 +54,11 @@ interactions:
x-ratelimit-endpoint-limit:
- unlimited
x-ratelimit-endpoint-remaining:
- '-778'
- '-2506'
x-ratelimit-method-limit:
- '10'
- '30'
x-ratelimit-method-remaining:
- '9'
- '29'
x-ratelimit-pubsub-limit:
- '5'
x-ratelimit-pubsub-remaining:
Expand All @@ -78,7 +70,7 @@ interactions:
x-ratelimit-tier:
- free
x-rpc-node:
- lon68
- fra113
status:
code: 200
message: OK
Expand Down
40 changes: 16 additions & 24 deletions blockapi/test/v2/api/cassettes/test_parse_metaplex_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,51 @@ interactions:
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
- python-requests/2.32.5
method: GET
uri: https://gateway.pinata.cloud/ipfs/QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe
response:
body:
string: !!binary |
H4sIAAAAAAAAAwAAAP//RI9Ba8JAFITv/oohZzVYLAVvWjwI1dqq0FJ6eJs8s6vJ7rr7Qkyl/70k
Hnp8wzfzZm4DILFUcTJDMs8EK8yw14z5CtvgvOasTYYdFNtKubLHnvd3yVRU9EYt4uMsTQsSbqgd
e2NJaJyVrs5T448xfat202qaLU71uXj61Ka66OP7QT34w3KqFtsPFdR6oR71z3WjDvN7fM4xC8aL
cfa/nYlwluGOEM04cgMf3IkzieCrL10wtoB2DcSBbUEFozGiuz2KW2dzEDJX5iCbI6fKYzJydjRB
HTmkFKOJQlbgKVBuimoIVQsogmBZGhfO3W++1FTGe02+CttonI3JDLffXhMquutrAADJ7vVlvrmP
ApL1cr1MBsB3T2aBSVzorYPfPwAAAP//AwAE4qjcjwEAAA==
string: "{\n \"name\": \"Act I : The AI Prophecy\",\n \"symbol\": \"ACT\",\n
\ \"image\": \"https://gateway.pinata.cloud/ipfs/QmS4m4cBjukg7YhimqhfRUb2pUE4bBPXbrbMBb5hzxNbUA\",\n
\ \"description\": \"Act I is one of the few projects exploring how to engage
with AI beyond a cold and damp 1-on-1 user/assistant paradigm, but as a network
of equals\",\n \"extensions\": {},\n \"tags\": [\n \"SOLANA\",\n \"MEME\"\n
\ ],\n \"creator\": {}\n}"
headers:
Access-Control-Allow-Origin:
- '*'
Age:
- '198388'
- '4776'
CF-Cache-Status:
- HIT
CF-Ray:
- 8d688cb5c809cbf3-MAD
- 976409232f4f80e8-PRG
Cache-Control:
- public, max-age=864000
- public, max-age=29030400
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
Date:
- Tue, 22 Oct 2024 09:44:35 GMT
- Thu, 28 Aug 2025 13:08:13 GMT
ETag:
- W/"QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe"
Expires:
- Fri, 01 Nov 2024 09:44:35 GMT
- Thu, 30 Jul 2026 13:08:13 GMT
Server:
- cloudflare
Set-Cookie:
- _cfuvid=s8i55DXcFh0WBxtugckw0rwrB6ACUXr.ttgTn8ZQbvc-1756386493815-0.0.1.1-604800000;
path=/; domain=.pinata.cloud; HttpOnly; Secure; SameSite=None
Strict-Transport-Security:
- max-age=15724800; includeSubDomains
- max-age=31536000; includeSubDomains
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding
Via:
- 1.1 3e64b4bceb49543044d7ca6510e86e3a.cloudfront.net (CloudFront)
X-Robots-Tag:
- noindex
access-control-allow-headers:
Expand All @@ -75,18 +75,10 @@ interactions:
content-security-policy:
- 'default-src ''self''; img-src * data: blob: ''unsafe-inline''; style-src
* ''unsafe-inline'''
x-amz-cf-id:
- Q2h-wBzIZXZ7r_fJ0O1vRsDizW7pZVa6jf0Ig2nKKR60zWRFmKpIow==
x-amz-cf-pop:
- MAD56-P1
x-cache:
- Hit from cloudfront
x-ipfs-path:
- /ipfs/QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe
x-ipfs-roots:
- QmVfMPCUPs5V1omaDvoni38w8aEJpFTjEZRNRmoVyexXWe
x-request-id:
- 9d0047ad6bed38faa10f9dd5ae9de7b1
status:
code: 200
message: OK
Expand Down
Loading