Api CoinMarketCap
Closed this issue · 0 comments
The CoinMarketCap API is a suite of high-performance RESTful JSON endpoints that are specifically designed to meet the mission-critical demands of application developers, data scientists, and enterprise business platforms.
This API reference includes all technical documentation developers need to integrate third-party applications and platforms. Additional answers to common questions can be found in the CoinMarketCap API FAQ.
For developers eager to hit the ground running with the CoinMarketCap API here are 3 quick steps to make your first call with the API.
Sign up for a free Developer Portal account. You can sign up for one of our two API environments:
sandbox.coinmarketcap.com - This testing sandbox has free access to all endpoints and all subscription plans to test with a snapshot of our market data.
pro.coinmarketcap.com - This is our live production environment with the latest market data. Select the free Basic plan if it meets your needs or upgrade to a paid tier.
Copy your API Key. Once you sign up you'll land on your Developer Portal account dashboard. Copy your API from the API Key box in the top left panel.
Make a test call using your key. You may use the code examples provided below to make a test call with your programming language of choice. This example fetches all active cryptocurrencies by market cap and return market values in USD.
Be sure to replace the API Key in sample code with your own and use API domain sandbox-api.coinmarketcap.com if testing with our sandbox.coinmarketcap.com environment.
Implement your application. Now that you've confirmed your API Key is working, get familiar with the API by reading the rest of this API Reference and commence building your application!
Note: Making HTTP requests on the client side with Javascript is currently prohibited through CORS configuration. This is to protect your API Key which should not be visible to users of your application so your API Key is not stolen. Secure your API Key by routing calls through your own backend service.
Python
#This example uses Python 2.7 and the python-request library.
from requests import Request, Session
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
import json
url = 'https://undefined/v1/cryptocurrency/listings/latest'
parameters = {
'start':'1',
'limit':'5000',
'convert':'USD'
}
headers = {
'Accepts': 'application/json',
'X-CMC_PRO_API_KEY': 'b54bcf4d-1bca-4e8e-9a24-22ff2c3d462c',
}
session = Session()
session.headers.update(headers)
try:
response = session.get(url, params=parameters)
data = json.loads(response.text)
print(data)
except (ConnectionError, Timeout, TooManyRedirects) as e:
print(e)