HTTP request tasks
Create ⚡️claimr tasks that utilize HTTP requests to interact with your own APIs.
Last updated
Was this helpful?
Create ⚡️claimr tasks that utilize HTTP requests to interact with your own APIs.
Last updated
Was this helpful?
HTTP request tasks allow you to integrate your own APIs into your claimr quests, giving you greater flexibility and control over task completion logic.
Use HTTP requst tasks to
Leverage your existing API infrastructure.
Configure tasks without requiring specific settings within claimr.
Define custom logic for task completion based on the response from your API.
This section allows you to choose the specific type of task you want to create for your campaign.
Select Web
: This indicates that the task involves interactions with a web-based platform or service.
Choose HTTP Request
: From the expanded list of web-based task types, select HTTP Request
.
Now, you are able to configure the specific settings for your task, such as the endpoint URL, request method, and response handling.
This section allows you to configure the specifics of your HTTP request task.
Enter the URL of your API endpoint that claimr will send the HTTP request to. It's essential to provide the correct and complete URL, including any necessary paths or parameters. This ensures the request reaches the intended destination on your server.
Return value:
HTTP 200 Status Code: Indicates that the request was successfully received, understood, and accepted by the server.
Exceptions (0, "0", false): Even if the status code is 200, the actual content of the response is checked. If the response body is 0, "0", or false, it is treated as a failure or an invalid response despite the successful status code.
Example: When making an API call, your application might consider the request successful only if:
The server responds with a status code of 200.
The response body contains meaningful data (not 0, "0", or false).
claimr provides tags that can be used to dynamically insert values into the endpoint URL. They are useful when you need to include user-specific or campaign-related information in the request.
{{address}}
the user's account identifier.
{{cs_address}}
the checksum address of the user's wallet.
{{week_start_iso}}
the start of the week in ISO 8601 format (YYYY-MM-DD).
{{week_end_iso}}
the end the week in ISO 8601 format.
{{day_start_iso}}
the start the day in ISO 8601 format.
{{day_end_iso}}
the end of the day in ISO 8601 format.
{{quest_id}}
the unique ID of the current quest.
{{task_id}}
the unique ID of the current task.
{{input}}
the value entered by the user in the task's input field (if enabled).
Example:
This endpoint URL will dynamically include the user's account identifier and the current task ID when the HTTP request is sent.
Select the HTTP request method that claimr will use when communicating with your API. The available options are:
GET
: When you send a GET request, your API will return the requested data without modifying anything on the server. This is useful for retrieving information like user details, account balances, or campaign statistics.
POST
: A POST request sends data to your API to create or update a resource. This is often used for actions like submitting user information, registering new accounts, or processing payments.
PUT
: A PUT request updates existing data on your API. This is typically used for modifying existing resources, such as updating user profiles, changing settings, or replacing data.
Headers enhance the security and functionality of your HTTP requests. Use them to transmit sensitive information like authentication tokens or API keys, which verify the legitimacy of the request and prevent unauthorized access to your API.
The screenshot provides a visual example of how headers are added. The specific header ("x-access-token") and value shown are illustrative and don't represent an actual header used in claimr. Include custom headers in your HTTP request to provide additional context and instructions to your API.
Use headers for these purposes:
Authentication: Include an authentication token or API key to verify the request's origin and prevent unauthorized access.
Content Negotiation: Specify the format of the data being sent or requested (e.g., JSON, XML).
Caching: Control how your API caches the request or response.
Use this field to include a request body in your HTTP request. The request body contains the data sent to your API endpoint. The format of this data depends on the Request type
you selected:
POST
and PUT
requests: Use JSON to structure the data in the request body. This allows you to send complex data structures to your API.
GET
requests: Request bodies are generally not used with GET
requests.
claimr tags mentioned in the endpoint section can also be used for the request body filed.
Use this field to add a JavaScript script to process the response from your API. This is useful when the response is complex or requires custom logic to determine task completion or calculate rewards.
response
object: The script has access to a response
object, which contains the data returned by your API. You can use JavaScript code to extract values, perform calculations, or apply conditions to this data.
Return value: The script must return a value that claimr will use to determine the task outcome:
Boolean (true
or false
): Indicates whether the task is completed.
Number: Specifies the number of points to award for completing the task.
Calculating rewards based on transactions
This example calculates the number of points to award based on the number of transactions (tx_count
) reported by the API. Each transaction is worth 10 points, so the script multiplies the tx_count
by 10 and returns the result.
This example checks if the API response indicates that the user has made any transactions (tx_count
). If the tx_count
is greater than 0, the task is marked as complete (true
).
This field allows you to specify the platform or context for your HTTP request task. It's used in specific situations where you need to differentiate between different environments or integrate with claimr's token generation feature.
How to specify the Platform:
For external APIs: Use a simple identifier that represents the platform. Example: Telegram
For claimr token generation: Use the organization ID, followed by two colons (::
), and then the platform name used during token generation. This helps claimr correctly identify the user account and associate it with the task.
In the screenshot, the platform is specified as ExamplE1::my_platform
. This indicates that the task is associated with the organization ID ExamplE1
and the platform my_platform
, which was likely used during token generation.
When to leave blank:
claimr as the platform: If you're using claimr's built-in functionality and not interacting with an external API, you should leave this field blank.
simple API integration: If your API doesn't have platform-specific requirements, you can also leave this field blank.
Important note about Endpoint field:
When using claimr's token generation and specifying a platform in this field, the Endpoint
field should include the account identifier. This ensures that claimr can correctly identify the user based on the account used during token generation.
You can define a regular expression (regex) to validate user input. This is useful when you want to ensure that users provide data in a specific format or pattern.
In the screenshot, the regex is used to validate Twitter links. This regex will ensure that any input provided by the user matches the expected format of a Twitter URL.
Customize the text displayed on the button that users click to submit their input for the task. This can help provide clearer instructions or context to the user. Example: Send link.
Enable an input field for the user to provide data for the task. If the toggle is disabled, the task will not require any user input.
Provide a label for the input field. This label helps users understand what kind of information they need to enter. Example: "Twitter link" clearly indicating that the user needs to provide a Twitter link in the input field.
Gift code: Ask users to enter a gift code they received and use your API to verify its validity.
Link: Ask users to submit a link to their social media profile or a specific webpage and use a regex to ensure the link is in the correct format.
claimr provides a built-in testing tool to help you verify that your HTTP request task is configured correctly and functions as expected. This tool allows you to simulate a user attempting the task and see the response from your API.
Access the test section: Within the task settings, you'll find a section labeled Test. This section provides fields and a button for testing your task.
Provide test data:
Test address: Enter a test address or value that will be used in the HTTP request. This could be a user's wallet address, a test API key, or any other relevant data that your API expects.
Test input value: If your task requires user input, enter a test value here. This value will be included in the HTTP request as if a user had submitted it.
Run the script: Click button to simulate the task execution. claimr will send the HTTP request to your API endpoint, using the provided test data and any configured headers or scripts.
View the response: The testing tool will display the response received from your API. This allows you to verify that your API is responding correctly and that your task script (if any) is processing the response as expected.
This setting determines how often users can complete the HTTP request task.
Once: This is the default setting. Users can only complete the task once.
Daily: The task resets every day, allowing users to complete it again each day.
Weekly: The task resets every week, allowing users to complete it again each week.
While setting up your HTTP request task, it's important to double-check your settings to avoid errors. Ensure that you have entered the correct endpoint URL and selected the appropriate request type. If you're using any claimr tags, make sure they are correctly formatted.
Let's say a user needs to complete a KYC (Know Your Customer) verification on your platform. This could involve verifying their identity using their wallet address. Create an HTTP request task in claimr to check if the user has successfully completed KYC. Here's how it works:
KYC Verification on your platform: The user goes through the KYC process on your platform, which likely involves verifying their identity through their wallet.
API endpoint for KYC status: Your platform has an API endpoint that allows you to check the KYC status of a user based on their wallet address.
HTTP request task in claimr: You create an HTTP request task in claimr with the following settings:
Endpoint: The URL of your KYC status API endpoint.
Request Type: GET
(since you're retrieving information).
Headers: Any necessary headers for authentication or authorization to your API.
Dynamic wallet address: In the endpoint URL, use a tag to dynamically insert the user's wallet address into the request.
API response: When a user attempts the task, claimr sends a GET request to your API endpoint, including the user's wallet address. Your API checks its database and returns a response indicating whether the user has passed KYC verification.
Task completion: claimr checks the API response. If the response confirms that the user has passed KYC, the task is marked as complete. If not, the task remains incomplete.
Provide placeholder text within the input field. This text can provide further guidance or examples to the user. Example: "Enter your Twitter link here" or "e.g., ".