API Ninja
Access a collection of easy-to-use, lightweight APIs for developers.
API Ninja
-
Step 1: Install the Skyfire SDK
npm install @skyfire-xyz/skyfire-sdk
pip install skyfire-sdk
-
Step 2: Initialize the SDK
import { SkyfireClient } from '@skyfire-xyz/skyfire-sdk' const skyfire = new SkyfireClient({ apiKey: 'YOUR_API_KEY' })
import skyfire_sdk configuration = skyfire_sdk.Configuration( host = "https://api.skyfire.xyz" ) configuration.api_key["ApiKeyAuth"] = "YOUR_API_KEY"
-
Step 3: Call any of the API Ninja services supported by the SDK
// Get the price of a crypto token by symbol async function getCryptoPrice(symbol: string): Promise<any>{ let res = await skyfire.apiNinja.cryptoPrice(symbol) // use cryptoPriceWithHttpInfo() for response headers included in the response return res }
# get the price of a crypto token given the symbol with skyfire_sdk.ApiClient(configuration) as api_client: api_instance = skyfire_sdk.APINinjaApi(api_client) symbol = "LTCBTC" api_response = api_instance.crypto_price(symbol)
Additional API Ninja Services
IP lookup
// get location information from an ip address
async function ipLookup(address: string): Promise<any>{
let res = await skyfire.apiNinja.ipLookup(address)
// use ipLookUpWithHttpInfo() for response headers included in the response
console.log(res)
return res
}
# get location information from an ip address
with skyfire_sdk.ApiClient(configuration) as api_client:
api_instance = skyfire_sdk.APINinjaApi(api_client)
api_response = api_instance.ip_lookup('184.187.138.224')
# use ip_lookup_with_http_info() for response headers included in the response
Stock price
// get the stock price of a company
async function getStockPrice(ticker: string): Promise<any>{
let res = await skyfire.apiNinja.stockPrice(ticker)
// use stockPriceWithHttpInfo() for response headers included in the response)
return res
}
# get the stock price of a company
with skyfire_sdk.ApiClient(configuration) as api_client:
api_instance = skyfire_sdk.APINinjaApi(api_client)
api_response = api_instance.stock_price('GOOGL')
# use ip_lookup_with_http_info() for response headers included in the response
Weather data
// get weather data from a location given location coordinates
async function weatherInfo(lat: number, long: number): Promise<any>{
let res = await skyfire.apiNinja.weather(lat, long)
// use weatherWithHttpInfo() for response headers included in the response
return res
}
# get weather data from a location given location coordinates
with skyfire_sdk.ApiClient(configuration) as api_client:
api_instance = skyfire_sdk.APINinjaApi(api_client)
api_response = api_instance.weather(34.4358, 119.8276)
# use weather_with_http_info() for headers included in the response
Updated about 1 month ago