Capture Token

Acquire Capture Token

Most of the Capture API only requires the user token and does not acquire any API key. You can signin with email or wallet to acquire the Capture Token. Here are examples to login and get your API tokens

Login with Email

curl -X POST https://api.numbersprotocol.io/api/v3/auth/token/login/ \
     -H "Content-Type: application/json" \
     -d '{"email": "[email protected]","password": "your_password"}'

Here is the sample token returned after login successfully:

{
    "auth_token": "02e6fd05701f49a8d1bd94bf814cfcf0eba5b98a"
}

Login with Wallet

The process of logging in with the integrity wallet involves a few steps that must be followed in order. These steps are outlined below:

  1. Make a GET request to the login-web3 endpoint, including the wallet address as a query parameter. This request will retrieve a message that needs to be signed.

  2. Using client-side code, sign the message with the wallet. This can be done with a library such as MetaMask, for example.

  3. Send a POST request to the same endpoint, including the address and signature in the request body.

  4. In the response, retrieve the authorization token.

Here is an example to login with your integrity wallet:

const url = `https://api.numbersprotocol.io/api/v3/auth/token/login-web3/`;

// Request the user's address from their wallet using the 'eth_requestAccounts' method
const address = (await ethereum.request({ method: 'eth_requestAccounts' }))[0];

// Send a GET request to the server to receive the message to be signed
let getResponse = await fetch(`${url}?address=${address}`));

// Get the message to be signed from the response
let message = (await getResponse.json()).message;

// Sign the message with the user's wallet
let signature = await ethereum.request({method: 'personal_sign', params: [address, message]});

// Send a POST request to the server with the address and signature to retrieve the auth token
let postResponse = await fetch(`${endpoint}`, {
    method: 'POST',
    body: JSON.stringify({address, signature}),
    headers: {'Content-type': 'application/json'}
});

// Get the auth token from the response
let authToken = (await postResponse.json()).auth_token;

Verify Capture Token

The /v3/auth/users/me/ endpoint is an authentication endpoint that allows for the validation of a user's Capture token.

By making a request to this endpoint with a valid token included in the headers, the user is able to verify their token and access the resources or services that are protected by the token. This endpoint is useful for ensuring that a user is authorized to access certain content or perform certain actions on a website or application. Additionally, this endpoint could also be used to check the validity of a token during a user's session.

The following sample code can be used to validate the Capture Token.


curl -X GET https://api.numbersprotocol.io/api/v3/auth/users/?show_num_balance=true \
     -H "Authorization: token $USER_CAPTURE_TOKEN"

The response.data.results[0] is the JSON object containing the user information. Following is an example of a JSON object returned by an API endpoint. The object contains information about a user, including their address, username, email, language, and wallet information. The user_wallet field contains various wallet addresses and their corresponding NUMs. The referrer field is the username of the user who referred the current user, and referral_code is the code that the current user can give to others for referral. The referee_count is the number of users that joined using the current user's referral code. The joined_at field is the date and time when the user created their account.

{
    "address": "0x8212099e5aF75e555A3E63da77a99CcC9527aCC1" # integrity wallet and also the ID of this user
    "username": "string", # username for the user, unique in the network
    "email": "[email protected]", # email address of the user
    "language": "en", # language preference of the user
    "user_wallet": {
        "asset_wallet": "string", # wallet address for the user's assets
        "asset_wallet_num": "string", # NUM balance in the asset wallet
        "integrity_wallet": "string", # wallet address for the user's integrity
        "integrity_wallet_num": "string", # NUM balance in the integrity wallet
        "points": "string", # Capture Credits in the user account
    },
    "referrer": "string", # user who referred the current user
    "referral_code": "string", # referral code assigned to the current user
    "referee_count": "string", # number of users that joined using the current user's referral code
    "joined_at": "2023-01-22T08:36:58Z" # date and time when the user created their account
    ...
}

More details can be found in this API doc.

Last updated

#100: Add a page: Import an NFT to Capture

Change request updated