### Installation Source: https://www.npmjs.com/package/@merkl/api/index Install the @merkl/api package into your project using npm. ```APIDOC ## Installation To begin, install the `@merkl/api` package into your project: ```bash npm install @merkl/api ``` ``` -------------------------------- ### Install @merkl/api NPM Package Source: https://www.npmjs.com/package/@merkl/api/package/%40merkl/api_activetab=readme Installs the @merkl/api package into your project using npm. This is the first step to using the Merkl API in your JavaScript or TypeScript application. ```bash npm install @merkl/api ``` -------------------------------- ### Usage Example: Import and Instantiate Source: https://www.npmjs.com/package/@merkl/api/index Import the Merkl API package and instantiate the Merkl API object with the base URL. ```APIDOC ## Usage Example: Import and Instantiate ### Import the Merkl API Package ```javascript import { MerklApi } from '@merkl/api' ``` ### Instantiate the Merkl API Object Initialize the Merkl API object by providing the base URL. Developers can leverage autocomplete features in their IDEs since all methods are strongly typed, ensuring a seamless development experience: ```javascript const merkl = MerklApi('https://api.merkl.xyz').v4 ``` ``` -------------------------------- ### API Call: Get Opportunities Source: https://www.npmjs.com/package/@merkl/api/index Retrieve a list of opportunities filtered by a specific chainId. ```APIDOC ## API Call: Get Opportunities Retrieve a list of opportunities filtered by a specific `chainId`: ```javascript const opportunities = await merkl.opportunities.index.get({ query: { chainId: '1' }, }) console.log(opportunities.data) ``` ### Parameters #### Query Parameters - **chainId** (string) - Required - The ID of the chain to filter opportunities by. ``` -------------------------------- ### Import Merkl API Package in JavaScript Source: https://www.npmjs.com/package/@merkl/api/package/%40merkl/api_activetab=readme Imports the MerklApi class from the installed @merkl/api package. This allows you to use the Merkl API functionalities in your code. ```javascript import { MerklApi } from '@merkl/api' ``` -------------------------------- ### API Call: Get Campaigns Rewarding USDC Source: https://www.npmjs.com/package/@merkl/api/index Retrieve campaigns filtered by token symbol, such as USDC. ```APIDOC ## API Call: Get Campaigns Rewarding USDC Retrieve campaigns filtered by token symbol, such as `USDC`: ```javascript const campaignsUSDC = await merkl.campaigns.index.get({ query: { tokenSymbol: 'USDC' }, }) console.log(campaignsUSDC.data) ``` ### Parameters #### Query Parameters - **tokenSymbol** (string) - Required - The symbol of the token to filter campaigns by. ``` -------------------------------- ### API Call: Get Rewards for a Specific Address Source: https://www.npmjs.com/package/@merkl/api/index Retrieve rewards for a specific user address, filtered by chainId. ```APIDOC ## API Call: Get Rewards for a Specific Address Retrieve rewards for a specific user address. Note that all methods are strongly typed for better developer experience: ```javascript const rewards = await merkl .users({ address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', }) .rewards.get({ query: { chainId: 1 } }) console.log(rewards.data) ``` ### Parameters #### Path Parameters - **address** (string) - Required - The user's wallet address. #### Query Parameters - **chainId** (number) - Required - The ID of the chain to filter rewards by. ``` -------------------------------- ### Get User Rewards by Address in JavaScript Source: https://www.npmjs.com/package/@merkl/api/package/%40merkl/api_activetab=readme Fetches rewards for a specific user address, filtered by chain ID. The user's address is passed as a path parameter, and chainId as a query parameter. ```javascript const rewards = await merkl .users({ address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', }) .rewards.get({ query: { chainId: 1 } }) console.log(rewards.data) ``` -------------------------------- ### Get Campaigns by Token Symbol in JavaScript Source: https://www.npmjs.com/package/@merkl/api/package/%40merkl/api_activetab=readme Retrieves a list of campaigns from the Merkl API, filtered by a specific token symbol (e.g., 'USDC'). The tokenSymbol is passed as a query parameter. ```javascript const campaignsUSDC = await merkl.campaigns.index.get({ query: { tokenSymbol: 'USDC' }, }) console.log(campaignsUSDC.data) ``` -------------------------------- ### Get Opportunities by Chain ID in JavaScript Source: https://www.npmjs.com/package/@merkl/api/package/%40merkl/api_activetab=readme Retrieves a list of opportunities from the Merkl API, filtered by a specific chain ID. The 'chainId' is passed as a query parameter. ```javascript const opportunities = await merkl.opportunities.index.get({ query: { chainId: '1' }, }) console.log(opportunities.data) ``` -------------------------------- ### Import and Instantiate Merkl API Object Source: https://www.npmjs.com/package/@merkl/api/index Demonstrates how to import the MerklApi class and instantiate it with the API base URL. The resulting object is strongly typed, providing autocomplete and early error detection. ```javascript import { MerklApi } from '@merkl/api' const merkl = MerklApi('https://api.merkl.xyz').v4 ``` -------------------------------- ### Instantiate Merkl API Object in JavaScript Source: https://www.npmjs.com/package/@merkl/api/package/%40merkl/api_activetab=readme Initializes the Merkl API object for version 4 by providing the base URL. This object will be used to make subsequent API calls. ```javascript const merkl = MerklApi('https://api.merkl.xyz').v4 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.