APIs
Here are some of the endpoints you'd require to get neccessary information to perform transactions
baseUrl = https://api.paycrest.io/v1
Fetch Token Rate
Endpoint: {baseUrl}/rates/:token/:amount/:fiat
Method: GET
Path Parameters
token
: The cryptocurrency token for which you wish to fetch the rate.amount
: The amount of the cryptocurrency token. Larger amounts could have better rates.fiat
: The local currency to which you want to convert the cryptocurrency token amount.
Query Parameters
provider_id
: The ID of a provider. Use this to get the rate of a specific liquidity provider
Response Format
A successful response from the GET {baseUrl}/rates/:token/:amount/:fiat
endpoint will contain a JSON object with the following structure:
{
"message": "OK",
"status": "success",
"data": "1500"
}
function App() { const [rate, setRate] = useState(""); const [loading, setLoading] = useState(false); const fetchTokenRate = async () => { try { setLoading(true); const response = await fetch( "https://api.paycrest.io/v1/rates/usdt/1/ngn" ); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } let res = await response.json(); setRate(JSON.stringify(res)); } catch (error) { console.error("Error fetching NGN rates:", error); throw error; } finally { setLoading(false); } }; return ( <div> <button onClick={fetchTokenRate}> {!loading ? `Fetch token` : `Loading rates...`} </button> <div>{rate}</div> </div> ); }
Fetch Supported Institutions
Endpoint: {baseUrl}/institutions/:currency_code
Method: GET
Response Format
A successful response from the GET {baseUrl}/institutions/:currency_code
endpoint will contain a JSON object with the following structure:
{
"message": "OK",
"status": "success",
"data": [
{
"name": "GT Bank Plc",
"code": "GTBINGLA",
"type": "bank" // bank or mobile_money
},
{
"name": "First Bank of Nigeria",
"code": "FBNINGLA",
"type": "bank" // bank or mobile_money
}
]
}
function App() { const [institutions, setInstitutions] = useState(""); const [loading, setLoading] = useState(false); const getInstitutions = async () => { try { setLoading(true); const response = await fetch( "https://api.paycrest.io/v1/institutions/ngn" ); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } let res = await response.json(); setInstitutions(JSON.stringify(res)); } catch (error) { console.error("Error fetching NGN institutions:", error); throw error; } finally { setLoading(false); } }; return ( <div> <button onClick={getInstitutions}> {!loading ? `Fetch NGN institutions` : `Loading NGN institutions...`} </button> <div>{institutions}</div> </div> ); }
Verify Account
Endpoint: {baseUrl}/verify-account
Method: POST
Payload
A JSON object containing the recipient account details.
Field name | Type | Required | Comment |
---|---|---|---|
institution | string | Yes | The code of the financial institution receving the local currency. Fetch supported institutions |
accountIdentifier | string | Yes | The recipient's bank or mobile money account number |
{
"institution": "FBNINGLA",
"accountIdentifier": "123456789"
}
Response Format
A JSON object containing the receive address to accept the cryptocurrency token.
{
"message": "Account name was fetched successfully",
"status": "success",
"data": "John Doe" // will return "OK" if PSP doesn't support name resolution
}
function App() { const [bankDeets, setBankDeets] = useState(""); const [loading, setLoading] = useState(false); const verifyBank = async () => { const bankData = { institution: "KUDANGPC", accountIdentifier: "12345678953", // sample account identifier }; try { setLoading(true); const response = await fetch( "https://api.paycrest.io/v1/verify-account", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(bankData), } ); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } let res = await response.json(); setBankDeets(JSON.stringify(res)); } catch (error) { console.error("Error fetching NGN rates:", error); throw error; } finally { setLoading(false); } }; return ( <div> <button onClick={verifyBank}> {!loading ? `Fetch bank details` : `Loading bank details...`} </button> <div>{bankDeets}</div> </div> ); }
Fetch Supported Currencies
Endpoint: {baseUrl}/currencies
Method: GET
Response Format
A successful response from the GET {baseUrl}/currencies
endpoint will contain a JSON object with the following structure:
{
"message": "OK",
"status": "success",
"data": [
{
"code": "XOF-BEN",
"name": "West African CFA franc",
"shortName": "Céfa Benin",
"decimals": 2,
"symbol": "CFA",
"marketRate": "599.5"
},
{
"code": "NGN",
"name": "Nigerian Naira",
"shortName": "Naira",
"decimals": 2,
"symbol": "₦",
"marketRate": "1629.59"
},
{
"code": "KES",
"name": "Kenyan Shilling",
"shortName": "KES",
"decimals": 2,
"symbol": "KSh",
"marketRate": "129.3"
}
]
}
function App() { const [currencies, setCurrencies] = useState(""); const [loading, setLoading] = useState(false); const getCurrencies = async () => { try { setLoading(true); const response = await fetch("https://api.paycrest.io/v1/currencies"); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } let res = await response.json(); console.log(res); setCurrencies(JSON.stringify(res)); } catch (error) { console.error("Error fetching currencies:", error); throw error; } finally { setLoading(false); } }; return ( <div> <button onClick={getCurrencies}> {!loading ? `Fetch currencies` : `Loading currencies...`} </button> <div>{currencies}</div> </div> ); }
Fetch Payment Order by ID
Endpoint: {baseUrl}/sender/orders/:id
Method: GET
Path Parameters
id
: The unique identifier for the order