### Quick Start Example (TypeScript) Source: https://docs.range.org/faraday-api/api-introduction A comprehensive TypeScript example demonstrating how to get a quote and submit a transaction using the Faraday SDK. ```APIDOC ## Quick Start Example (TypeScript) ```typescript import { FaradayClient } from '@rangesecurity/faraday-sdk'; const faraday = new FaradayClient({ apiKey: process.env.RANGE_API_KEY }); // 1. Get a quote const quote = await faraday.getQuote({ sourceChain: 'solana', sourceToken: 'USDT', destChain: 'ethereum', destToken: 'USDC', amount: '1000', slippageBps: 50 }); console.log('Quote:', quote); // 2. Execute the transaction const tx = await faraday.executeQuote(quote.id); console.log('Transaction submitted:', tx.id); // 3. Monitor status const status = await faraday.getTransaction(tx.id); console.log('Status:', status.state); ``` ``` -------------------------------- ### Install Faraday Examples Dependencies Source: https://docs.range.org/faraday-api/integration/setup Installs the necessary Node.js dependencies for the Faraday examples. This command should be run after cloning the repository and navigating into the directory. ```bash npm install ``` -------------------------------- ### Quick Start Example (cURL) Source: https://docs.range.org/faraday-api/api-introduction A cURL example illustrating how to interact with the Faraday API to get a quote, submit a transaction, and check its status. ```APIDOC ## Quick Start Example (cURL) ```bash # 1. Get a quote curl -G 'https://api.faraday.range.org/v1/transactions/quote' \ -H 'Authorization: Bearer YOUR_API_KEY' \ --data-urlencode 'from_chain=solana' \ --data-urlencode 'from_asset=USDT' \ --data-urlencode 'to_chain=ethereum' \ --data-urlencode 'to_asset=USDC' \ --data-urlencode 'amount=1000' \ --data-urlencode 'slippage_bps=50' # 2. Submit transaction (using quote ID from step 1) curl -X POST 'https://api.faraday.range.org/v1/transactions' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{"quote_id": "quote_abc123", "signed_tx": "0x..."}' # 3. Check status curl 'https://api.faraday.range.org/v1/transactions/tx_xyz789' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` ``` -------------------------------- ### Example Request (Bash) Source: https://docs.range.org/api-reference/persons/get-a-person-by-blockchain-address An example cURL command to demonstrate how to fetch persons using the Faraday API. It includes the necessary GET request to the persons endpoint and the Authorization header with a Bearer token. ```bash curl -X GET 'https://api.faraday.range.org/v1/persons' --header 'Authorization: Bearer ' ``` -------------------------------- ### Quick Start: Get Quote and Submit Transaction (TypeScript) Source: https://docs.range.org/faraday-api/api-introduction This TypeScript example demonstrates how to use the Faraday SDK to get a transaction quote, execute the quote, and monitor the transaction status. It requires the `RANGE_API_KEY` environment variable to be set. ```typescript import { FaradayClient } from '@rangesecurity/faraday-sdk'; const faraday = new FaradayClient({ apiKey: process.env.RANGE_API_KEY }); // 1. Get a quote const quote = await faraday.getQuote({ sourceChain: 'solana', sourceToken: 'USDT', destChain: 'ethereum', destToken: 'USDC', amount: '1000', slippageBps: 50 }); console.log('Quote:', quote); // 2. Execute the transaction const tx = await faraday.executeQuote(quote.id); console.log('Transaction submitted:', tx.id); // 3. Monitor status const status = await faraday.getTransaction(tx.id); console.log('Status:', status.state); ``` -------------------------------- ### GET /v1/address Source: https://docs.range.org/introduction/quickstart Retrieve comprehensive blockchain address data including labels, risk scores, and activity across chains. ```APIDOC ## GET /v1/address ### Description Retrieve comprehensive blockchain address data including labels, risk scores, and activity across chains. ### Method GET ### Endpoint `/v1/address` ### Parameters #### Query Parameters - **address** (string) - Required - The blockchain address to query. - **network** (string) - Required - The network of the address (e.g., 'solana'). ### Request Example **cURL** ```bash curl --location 'https://api.range.org/v1/address?address=CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3&network=solana' \ --header 'Authorization: Bearer your_api_key_here' ``` **JavaScript** ```javascript const address = "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3"; const network = "solana"; const response = await fetch( `https://api.range.org/v1/address?address=${address}&network=${network}`, { headers: { Authorization: "Bearer your_api_key_here", }, } ); const data = await response.json(); console.log(data); ``` ### Response #### Success Response (200) - **address** (string) - The queried blockchain address. - **ecosystem** (string) - The ecosystem of the address. - **network** (string) - The network of the address. - **name_tag** (string) - A human-readable name tag for the address. - **category** (string) - Categories associated with the address (e.g., 'DEFI, BRIDGE'). - **address_role** (string) - The role of the address (e.g., 'Program'). - **entity** (string) - Associated entity name. - **attributes** (object) - Additional attributes of the address. - **tags** (array) - Tags associated with the address. - **malicious** (boolean) - Indicates if the address is flagged as malicious. - **is_validator** (boolean) - Indicates if the address is a validator. #### Response Example ```json { "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", "ecosystem": "solana", "network": "solana", "name_tag": "CCTP TokenMessengerMinter", "category": "DEFI, BRIDGE", "address_role": "Program", "entity": "", "attributes": {}, "tags": [], "malicious": false, "is_validator": false } ``` ``` -------------------------------- ### Clone Faraday Examples Repository Source: https://docs.range.org/faraday-api/integration/setup Clones the Faraday examples repository from GitHub to your local machine. This repository contains pre-built examples to help you understand and integrate with Faraday. ```bash git clone https://github.com/rangesecurity/faraday-examples ``` -------------------------------- ### Run Faraday Quote Example (Bash) Source: https://docs.range.org/faraday-api/integration/getting-a-quote Executes the development command for generating quotes using the Faraday SDK. This command is typically run from the examples repository and will display a quote from an aggregator service if available. Users can modify network and token parameters to experiment. ```bash npm run dev:quote ``` -------------------------------- ### Get Address Information - Range API Source: https://docs.range.org/introduction/quickstart Retrieve comprehensive blockchain address data including labels, risk scores, and activity across chains. This example shows how to make the request using cURL, JavaScript, Python, and TypeScript. ```bash curl --location 'https://api.range.org/v1/address?address=CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3&network=solana' \ --header 'Authorization: Bearer your_api_key_here' ``` ```javascript const address = "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3"; const network = "solana"; const response = await fetch( `https://api.range.org/v1/address?address=${address}&network=${network}`, { headers: { Authorization: "Bearer your_api_key_here", }, } ); const data = await response.json(); console.log(data); ``` ```python import requests address = 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' network = 'solana' headers = { 'Authorization': 'Bearer your_api_key_here' } params = { 'address': address, 'network': network } response = requests.get( 'https://api.range.org/v1/address', headers=headers, params=params ) data = response.json() print(data) ``` ```typescript const address = "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3"; const network = "solana"; const response = await fetch( `https://api.range.org/v1/address?address=${address}&network=${network}`, { headers: { Authorization: "Bearer your_api_key_here", }, } ); const data = await response.json(); console.log(data); ``` -------------------------------- ### List Tokens API Request Example Source: https://docs.range.org/api-reference/tokens/list-tokens This bash command demonstrates how to make a GET request to the Faraday API's '/v1/tokens' endpoint to list supported tokens. It includes the necessary Authorization header with a Bearer token. ```bash curl -X GET 'https://api.faraday.range.org/v1/tokens' --header 'Authorization: Bearer ' ``` -------------------------------- ### TypeScript SDK Example for Stablecoin Transactions Source: https://docs.range.org/reference/faraday-introduction This example demonstrates how to use the Faraday TypeScript SDK to get the best quote for a stablecoin swap and then execute the transaction. It highlights the ease of integrating cross-chain and cross-denomination stablecoin transfers with built-in compliance checks. ```typescript import { FaradayClient } from '@rangesecurity/faraday-sdk'; const faraday = new FaradayClient({ apiKey: process.env.RANGE_API_KEY }); // Get best quote for USDT → USDC swap const quote = await faraday.getQuote({ sourceChain: 'solana', sourceToken: 'USDT', destChain: 'ethereum', destToken: 'USDC', amount: '1000' }); // Execute with built-in compliance checks const tx = await faraday.executeQuote(quote.id); ``` -------------------------------- ### Example GET Request for Persons (Bash) Source: https://docs.range.org/api-reference/chains/list-chains This bash script demonstrates how to make a GET request to the /v1/persons endpoint of the Faraday API. It includes the necessary Authorization header with a Bearer token. This endpoint is used for managing IVMS101 Person records. ```bash curl -X GET 'https://api.faraday.range.org/v1/persons' --header 'Authorization: Bearer ' ``` -------------------------------- ### Example API Request and Response Source: https://docs.range.org/risk-api/risk/get-payment-risk-assessment Demonstrates a cURL request to the Range Security API for a payment risk assessment and its corresponding JSON response. This example shows a high-risk scenario due to a new recipient wallet and a first-time interaction. ```bash curl -G https://api.range.org/v1/risk/payment \ --data-urlencode "sender_address=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" \ --data-urlencode "recipient_address=7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi" \ --data-urlencode "amount=1000.0" \ --data-urlencode "sender_network=solana" \ --data-urlencode "recipient_network=solana" ``` ```json { "overall_risk_level": "high", "risk_factors": [ { "factor": "new_wallet_recipient", "risk_level": "medium", "description": "Recipient is a completely new wallet with no transaction history" }, { "factor": "first_interaction", "risk_level": "high", "description": "First ever interaction between these addresses" } ], "processing_time_ms": 2456.78, "errors": [] } ``` -------------------------------- ### Error Handling Examples Source: https://docs.range.org/risk-api/risk/get-token-risk-assessment Examples of error responses for invalid input and network issues. ```APIDOC ## Error Handling Examples ### Invalid Address Format This error occurs when the provided `mint_address` does not conform to the expected base58 format and length. ```json { "detail": [ { "type": "string_pattern_mismatch", "loc": ["query", "mint_address"], "msg": "String should match pattern '^[1-9A-HJ-NP-Za-km-z]{32,44}$'", "input": "invalid_address", "ctx": { "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$" } } ] } ``` ### Network Error This error is returned when an unsupported blockchain network is specified. ```json { "error": "Unsupported network", "error_type": "validation_error", "detail": "Only 'solana' network is supported", "mint_address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" } ``` ``` -------------------------------- ### Assess Payment Risk (Low Risk - Established Relationship) Source: https://docs.range.org/risk-api/risk/get-payment-risk-assessment This example demonstrates how to assess the risk of a payment transaction with an established sender and recipient relationship. It uses the `curl` command to send a GET request to the `/v1/risk/payment` endpoint with relevant transaction details. The response indicates a 'low' overall risk level due to factors like an established wallet recipient and strong interaction history. ```bash curl -G https://api.range.org/v1/risk/payment \ --data-urlencode "sender_address=DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" \ --data-urlencode "recipient_address=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" \ --data-urlencode "amount=250.0" \ --data-urlencode "sender_network=solana" \ --data-urlencode "recipient_network=solana" \ --data-urlencode "sender_token=So11111111111111111111111111111111111111112" \ --data-urlencode "timestamp=2025-01-15T10:30:00Z" ``` -------------------------------- ### Get Solana Address Risk Score Source: https://docs.range.org/risk-api/risk/get-address-risk-score This example shows how to fetch the risk score for a Solana address via the Range API. Similar to the Ethereum example, it requires an API key and specifies the network as 'solana'. The output format is consistent with other network requests. ```bash curl --location 'https://api.range.org/v1/risk/address?address=7AmvTQJAQAseV53Sqbnwxm3MTKKy6chZa1rhT1FqRkfL&network=solana' \ --header 'Authorization: Bearer your_api_key_here"' ``` -------------------------------- ### Run Faraday Person Record Example (Bash) Source: https://docs.range.org/faraday-api/integration/compliance-record-keeping Executes the command to create a person record using the Faraday SDK from the examples repository. This command initiates a development server that processes a person payload. ```bash npm run dev:person ``` -------------------------------- ### Generate Test Keys for Faraday Examples Source: https://docs.range.org/faraday-api/integration/setup Generates new Ethereum and Solana keypairs for local testing purposes. This script saves the keys in the ./keys directory and prints the public addresses. These keys should not be used on mainnet. ```bash npm run dev:setup ``` -------------------------------- ### Get Celestia Network Address Score (Bash) Source: https://docs.range.org/risk-api/risk/get-address-risk-score This example shows how to use curl to get the risk score for an address on the Celestia network via the Range API. It includes the address and network parameters, authenticated with an API key. ```bash curl --location 'https://api.range.org/v1/risk/address?address=DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263&network=celestia' \ --header 'Authorization: Bearer your_api_key_here"' ``` -------------------------------- ### Example API Request with Pagination (Bash) Source: https://docs.range.org/data-api/api-reference-introduction Demonstrates how to make a paginated API request using curl, specifying the network, address, page number, and limit. It also shows how to include an authorization header. ```bash curl "https://api.range.org/v1/address/transactions?address=YOUR_ADDRESS&network=solana&page=2&limit=50" \ -H "Authorization: Bearer your_api_key_here" ``` -------------------------------- ### Copy Environment Sample File Source: https://docs.range.org/faraday-api/integration/setup Copies the sample environment file (.env.sample) to a new file (.env). This .env file is used to store your Range API key and other configuration settings for the Faraday examples. ```bash cp .env.sample .env ``` -------------------------------- ### Make First API Request (cURL, JavaScript, Python, TypeScript) Source: https://docs.range.org/data-api/api-reference-introduction Demonstrates how to make your first API call to fetch information about a Solana address using cURL, JavaScript, Python, and TypeScript. Requires an API key for authentication. ```bash curl -X GET "https://api.range.org/v1/address?address=CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3&network=solana" \ -H "Authorization: Bearer your_api_key_here" ``` ```javascript const response = await fetch( 'https://api.range.org/v1/address?address=CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3&network=solana', { headers: { 'Authorization': 'Bearer your_api_key_here' } } ); const data = await response.json(); console.log(data); ``` ```python import requests response = requests.get( 'https://api.range.org/v1/address', params={ 'address': 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3', 'network': 'solana' }, headers={'Authorization': 'Bearer your_api_key_here'} ) print(response.json()) ``` ```typescript const response = await fetch( 'https://api.range.org/v1/address?address=CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3&network=solana', { headers: { 'Authorization': 'Bearer your_api_key_here' } } ); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Low-Risk Solana Address Score (Bash) Source: https://docs.range.org/risk-api/risk/get-address-risk-score This example shows how to retrieve the risk score for a low-risk address on the Solana network using the Range API. The request includes the address and network, authenticated with an API key. ```bash curl --location 'https://api.range.org/v1/risk/address?address=2oP36hojo3spVLvrhqNVW8ERUEYMKFAS2XVAmFv289WJ&network=solana' \ --header 'Authorization: Bearer your_api_key_here"' ``` -------------------------------- ### Install Faraday TypeScript SDK Source: https://docs.range.org/faraday-api/architecture/faq Installs the Faraday SDK using npm. This SDK is recommended for full type safety, automatic authentication, and built-in error handling, compatible with both Node.js and browser environments. ```bash npm install @rangesecurity/faraday-sdk ``` -------------------------------- ### Get High-Risk Address Score (Bash) Source: https://docs.range.org/risk-api/risk/get-address-risk-score This example demonstrates how to use curl to query the Range API for the risk score of a high-risk address on the Solana network. It requires an API key for authentication and specifies the address and network as query parameters. ```bash curl -G https://api.range.org/v1/risk/address \ --data-urlencode "address=AuZrspySopxfZUiXY6YxDyfS211KvXLe197kj3M2cLpq" \ --data-urlencode "network=solana" \ -H "Authorization: Bearer your_api_key_here" ``` -------------------------------- ### Get Solana Token Program Address Score (Bash) Source: https://docs.range.org/risk-api/risk/get-address-risk-score This example demonstrates querying the Range API for the risk score of a Solana Token Program address, which is a known system address. The API correctly identifies and overrides the risk score for such addresses. ```bash curl --location 'https://api.range.org/v1/risk/address?address=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA&network=solana' \ --header 'Authorization: Bearer your_api_key_here"' ``` -------------------------------- ### Quick Start: Get Quote and Submit Transaction (cURL) Source: https://docs.range.org/faraday-api/api-introduction This set of cURL commands shows how to interact with the Faraday API to get a transaction quote, submit a transaction using the quote ID, and check the transaction status. Replace `YOUR_API_KEY` with your actual API key and `quote_abc123` and `tx_xyz789` with actual IDs. ```bash # 1. Get a quote curl -G 'https://api.faraday.range.org/v1/transactions/quote' \ -H 'Authorization: Bearer YOUR_API_KEY' \ --data-urlencode 'from_chain=solana' \ --data-urlencode 'from_asset=USDT' \ --data-urlencode 'to_chain=ethereum' \ --data-urlencode 'to_asset=USDC' \ --data-urlencode 'amount=1000' \ --data-urlencode 'slippage_bps=50' # 2. Submit transaction (using quote ID from step 1) curl -X POST 'https://api.faraday.range.org/v1/transactions' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{"quote_id": "quote_abc123", "signed_tx": "0x..."}' # 3. Check status curl 'https://api.faraday.range.org/v1/transactions/tx_xyz789' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### Get Ethereum Address Risk Score Source: https://docs.range.org/risk-api/risk/get-address-risk-score This example demonstrates how to retrieve the risk score for an Ethereum address using the Range API. It requires an API key for authorization and specifies the network as 'eth'. The response includes risk level, number of hops, and details about any malicious addresses found. ```bash curl --location 'https://api.range.org/v1/risk/address?address=0x5d87eaeb84c694a12e01c445fca0b1c527613c25&network=eth' \ --header 'Authorization: Bearer your_api_key_here"' ``` -------------------------------- ### API Authentication Header Example (Bash) Source: https://docs.range.org/data-api/api-reference-introduction Shows the required format for the Authorization header to authenticate API requests. This header must be included in every request to the Range API. ```bash Authorization: Bearer your_api_key_here ```