Privy offers low-level APIs you can use to interact with wallets and user objects directly. This means APIs to interface with the following resources:
- Users: create user objects with appropriate linked accounts and pregenerate wallets for them.
- Wallets: create, update and use wallets across blockchains.
- Authorization keys: create and manage authorization keys to manage wallets.
- Policies: create and manage policies tied to wallets.
Read more about direct API access below.
Base URL
All requests to the Privy API must be made to the following base URL:
HTTPS is required for all requests. HTTP requests will be rejected.
Authentication
All API endpoints require authentication using Basic Auth and a Privy App ID header. Include the following headers with every request:
Basic Auth header with your app ID as the username and your app secret as the password.
Your Privy app ID as a string.
Requests missing either of these headers will be rejected by Privy’s middleware.
Examples
fetch('https://api.privy.io/v1/wallets', {
method: 'GET',
headers: {
'Authorization': `Basic ${btoa('insert-your-app-id' + ':' + 'insert-your-app-secret')}`,
'privy-app-id': 'insert-your-app-id',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));
curl -X GET "https://api.privy.io/v1/wallets" \
--user "insert-your-app-id:insert-your-app-secret" \
-H "privy-app-id: insert-your-app-id" \
-H "Content-Type: application/json"
import requests
import base64
app_id = "insert-your-app-id"
app_secret = "insert-your-app-secret"
auth_string = f"{app_id}:{app_secret}"
encoded_auth = base64.b64encode(auth_string.encode()).decode()
headers = {
"Authorization": f"Basic {encoded_auth}",
"privy-app-id": app_id,
"Content-Type": "application/json"
}
response = requests.get("https://api.privy.io/v1/wallets", headers=headers)
data = response.json()