LogoLogo
  • Products
    • 🎯XP Protocol
      • Key Concepts
      • Features
        • Claims
      • Integrations
        • XP Subgraph
        • 📡Rest API
          • Endpoints
          • Rate limit
          • Authentication
        • ⚡Snapshot
        • 🖼️NFT Watcher
      • Design Patterns
        • 💰X-to-Earn Design Pattern
        • 🧑‍🤝‍🧑Referral Design Pattern
        • Social Tracking
Powered by GitBook
On this page
  • Intro
  • Valid score submission
  • Connecting
  • Example Request

Was this helpful?

  1. Products
  2. XP Protocol
  3. Integrations
  4. Rest API

Authentication

Intro

To connect to the XP API, you will need an authentication key provided by the XP team.

You can request one here -> contact@xp-protocol.io

Valid score submission

  1. You must be approved with a valid api key to submit scores to this endpoint.

  2. For a score to take effect, you must also sign the update with a wallet address that is approved as an "owner" or "updater" for that specific XP Project Id. (Can be added in your dashboard/Directly on contract)

Connecting

Connect using the "X-API-KEY" header in your request

"X-API-KEY":"<api-key>"

Example Request

let myHeaders = new Headers();
let message = Date.now().toString();
let signatureObject = await web3.eth.accounts.sign(message, <PRIVATE_KEY>);
let signature = signatureObject.signature;

//Headers
myHeaders.append("X-API-KEY","<key>");
myHeaders.append("Content-Type", "application/json");
  
  //Send to API
    const body = JSON.stringify({
        "updateId": updateId,
        "projectId": <PROJECT_ID>,
        "actionName": <action-name>,
        "scoreType": <scoreType>,
        "targetWallet": <targetAddress>,
        "signature": signature,
        "message": message
    })
    const requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: body,
        redirect: 'follow'
    };
    
    let response = await fetch('https://api.xp-protocol.io/update-score, requestOptions).then(async (response) => ({ status: response.status, value: await response.text() }));
PreviousRate limitNextSnapshot

Last updated 1 year ago

Was this helpful?

🎯
📡