### Install Paragraph SDK using npm Source: https://paragraph.com/docs/development/sdk/index Installs the Paragraph SDK package into your Node.js project. Ensure you have Node.js version 19 or higher installed. ```bash npm i @paragraph_xyz/sdk ``` -------------------------------- ### Fetch User Profile by Wallet Address (TypeScript) Source: https://paragraph.com/docs/development/sdk/examples Retrieves user profile information, including any associated Farcaster profiles, given a wallet address. This function calls the API to get the user details based on the provided wallet address. ```typescript /** * Given a wallet address, fetch the user profile including * any associated Farcaster profile. */ async function getUserProfileByWallet(walletAddress: string) { const user = await api.getUserByWallet(walletAddress) console.log("User profile:", user) } ``` -------------------------------- ### Install Paragraph MCP Server for Claude Code Source: https://paragraph.com/docs/development/ai/index This command installs the Paragraph MCP server, enabling direct API interaction, documentation search, and real-time API information access within AI clients like Claude Code. Ensure you have the necessary permissions to run CLI commands. ```bash claude mcp add --transport http paragraph https://paragraph.mintlify.app/mcp ``` -------------------------------- ### Instantiate ParagraphAPI Class Source: https://paragraph.com/docs/development/sdk/index Initializes the ParagraphAPI class, which is the main entry point for interacting with the Paragraph SDK. This class will be used to make subsequent API calls. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() ``` -------------------------------- ### Query Paragraph Data with SDK Source: https://paragraph.com/docs/development/sdk/index Demonstrates how to query data using the instantiated ParagraphAPI object. It shows fetching a publication by its slug and then retrieving all posts associated with that publication, logging the results to the console. ```typescript const slug = 'blog' const publication = await api.getPublicationBySlug(slug) console.log(`Fetched publication: ${publication}`) const postData = await api.getPosts(publication.id) const posts = postData.items console.log(`Fetched ${postData.length} posts from ${slug}, out of ${postData.pagination.total} posts: ${JSON.stringify(posts)} `) ``` -------------------------------- ### Get Post by Publication ID and Slug (TypeScript) Source: https://paragraph.com/docs/api-reference/posts/get-post-by-publication-id-and-post-slug This snippet demonstrates how to retrieve a post from the Paragraph API using its publication ID and post slug. It utilizes the `@paragraph_xyz/sdk` library for making the API call. The function takes publicationId and postSlug as arguments and returns the post data. Ensure the SDK is installed (`npm install @paragraph_xyz/sdk`). ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const post = await api.getPost({ publicationId: "BMV6abfvCSUl51ErCVzd", postSlug: "my-first-post" }) ``` -------------------------------- ### Fetch Paginated Posts using Paragraph SDK - TypeScript Source: https://paragraph.com/docs/development/sdk/examples Fetches posts from a given publication slug, demonstrating cursor-based pagination to retrieve multiple pages of posts. It uses the `getPublicationBySlug` and `getPosts` methods from the Paragraph SDK. The function returns the first two pages of posts and logs them to the console. ```typescript /** * Given a Paragraph publication slug, fetch the first two * pages of posts. */ async function fetchParagraphPosts(slug: string) { const publication = await api.getPublicationBySlug(slug) console.log("Publication:", publication) const posts = [] const firstBatch = await api.getPosts(publication.id, {}) posts.push(...firstBatch.items) console.log("Posts:", firstBatch.items) if (firstBatch.pagination.hasMore && firstBatch.pagination.cursor) { const secondBatch = await api.getPosts(publication.id, { cursor: firstBatch.pagination.cursor }) posts.push(...secondBatch.items) } console.log(`Last ${posts.length} posts from ${slug}, out of ${firstBatch.pagination.total} posts: ${JSON.stringify(firstBatch.items)}`) } ``` -------------------------------- ### Fetch Coin and Holders from Post (TypeScript) Source: https://paragraph.com/docs/development/sdk/examples Retrieves coin and holder information associated with a specific post using publication and post slugs. It requires the publication ID to fetch the post, and then uses the post's coinId to fetch coin details and holder data. ```typescript /** * Given a publication & post slug, fetch coin & holders. */ async function fetchCoinFromPost(publicationSlug: string, postSlug: string) { const publication = await api.getPublicationBySlug(publicationSlug) const publicationId = publication.id const post = await api.getPost({ publicationId: publicationId, postSlug: postSlug }) if (post.coinId) { const [coin, holders] = await Promise.all([ api.getCoin(post.coinId), api.getCoinHolders(post.coinId) ]) console.log("Fetched coin & holders from post:", coin, holders) } } ``` -------------------------------- ### Get Post by ID - TypeScript Source: https://paragraph.com/docs/api-reference/posts/get-post-by-id This TypeScript code snippet demonstrates how to retrieve a specific post by its ID using the Paragraph API SDK. It initializes the SDK and calls the getPost method with the post's unique identifier. Ensure the '@paragraph_xyz/sdk' package is installed. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const post = await api.getPost({ id: "3T2PQZlsdQtigUp4fhlb" }) ``` -------------------------------- ### Get User by ID - TypeScript Source: https://paragraph.com/docs/api-reference/users/get-user-by-id Retrieves a user's profile information by their unique identifier. This snippet utilizes the Paragraph API SDK for TypeScript. Ensure the SDK is installed and configured. It takes a user ID as input and returns user details or an error response. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const user = await api.getUser("AeAOtR8TqKWyzG5apA1R") ``` -------------------------------- ### Prompting Patterns for AI-Assisted API Integration Source: https://paragraph.com/docs/development/ai/index These are common prompting patterns to guide AI assistants in integrating Paragraph's API. They specify the endpoint, use case, language, and requirements like error handling and type definitions for effective code generation. ```text "Help me integrate Paragraph's [endpoint name] endpoint in [language/framework]. I need to [specific use case]. Include error handling and type definitions." ``` ```text "I'm getting [error message] when calling Paragraph's [endpoint]. Here's my code: [code snippet]. What's wrong?" ``` ```text "Based on Paragraph's API, help me create [language] models/interfaces for [specific data types] with proper type annotations." ``` -------------------------------- ### Get Coin by ID using TypeScript SDK Source: https://paragraph.com/docs/api-reference/coins/get-coin-by-id This code snippet demonstrates how to fetch coin details using the Paragraph API's TypeScript SDK. It requires the `@paragraph_xyz/sdk` package. The function takes a coin ID as a string and returns coin details or an error. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const coin = await api.getCoin("S2AlaNG5Hw0NdNptmLTw") ``` -------------------------------- ### Prompting for Data Modeling with AI Source: https://paragraph.com/docs/development/ai This prompt pattern guides AI in generating language-specific data models or interfaces based on Paragraph's API documentation. It's useful for creating strongly-typed structures for specific data types with proper annotations. ```prompt "Based on Paragraph's API, help me create [language] models/interfaces for [specific data types] with proper type annotations." ``` -------------------------------- ### Get Coin by Contract Address (TypeScript) Source: https://paragraph.com/docs/api-reference/coins/get-coin-by-contract-address This snippet demonstrates how to fetch coin details using the Paragraph API's `getCoinByContract` method. It requires the `@paragraph_xyz/sdk` package and takes a contract address as input. The output is a coin object containing its ID, contract address, symbol, and associated post ID, or an error if the coin is not found or an internal server error occurs. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const coin = await api.getCoinByContract("0xe9bb3166ff5f96381e257d509a801303b68e5d34") ``` -------------------------------- ### GET /websites/paragraph Source: https://paragraph.com/docs/api-reference/posts/get-post-by-publication-id-and-post-slug Retrieves a website paragraph by its publication ID and slug. ```APIDOC ## GET /websites/paragraph ### Description Retrieves a specific website paragraph using its unique publication ID and slug. ### Method GET ### Endpoint /websites/paragraph ### Parameters #### Query Parameters - **publicationId** (string) - Required - The ID of the publication. - **slug** (string) - Required - The slug of the paragraph. ### Request Example ```json { "publicationId": "examplePublicationId", "slug": "exampleSlug" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **msg** (string) - A message describing the result of the operation. - **error** (string) - Details about any error that occurred. #### Response Example ```json { "success": true, "msg": "Paragraph retrieved successfully.", "error": null } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses. - **msg** (string) - A human-readable error message. - **error** (string) - Technical error details or error code. #### Error Response Example ```json { "success": false, "msg": "Internal server error.", "error": "An unexpected error occurred." } ``` ``` -------------------------------- ### Get Publication by Slug using OpenAPI Source: https://paragraph.com/docs/api-reference/publications/get-publication-by-slug This OpenAPI definition specifies the `GET /v1/publications/slug/{slug}` endpoint for the Paragraph API. It allows retrieval of publication details by providing a URL-friendly slug. The definition includes request parameter schemas, response schemas for successful retrieval (200), publication not found (404), and internal server errors (500), along with a TypeScript code sample demonstrating its usage. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const publication = await api.getPublicationBySlug("blog") ``` -------------------------------- ### Paragraph Detection Logic Source: https://paragraph.com/docs/coins This snippet demonstrates the recommended logic for detecting paragraphs. It involves checking the asset's integrator against known paragraph integrators and verifying if the DERC20 tokenURI starts with a specific metadata URL pattern. No external dependencies are explicitly mentioned, and the output is a boolean condition. ```javascript getAssetData(asset).integrator == PARAGRAPH_INTEGRATOR[chainId] DERC20.tokenURI() starts with "https://api.paragraph.com/coins/metadata/…" ``` -------------------------------- ### GET /v1/coins/{id} Source: https://paragraph.com/docs/api-reference/coins/get-coin-by-id Retrieve information about a tokenized post using its unique ID. ```APIDOC ## GET /v1/coins/{id} ### Description Retrieve information about a tokenized post using its unique ID. ### Method GET ### Endpoint https://public.api.paragraph.com/api/v1/coins/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Paragraph-internal unique identifier for the coin #### Query Parameters #### Request Body ### Request Example ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const coin = await api.getCoin("S2AlaNG5Hw0NdNptmLTw") ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the coin - **contractAddress** (string) - Base contract address for the coin - **symbol** (string) - Token symbol - **postId** (string) - ID of the post this token is associated with #### Response Example ```json { "id": "", "contractAddress": "", "symbol": "", "postId": "" } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Response Example ```json { "success": true, "msg": "", "error": "" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Response Example ```json { "success": true, "msg": "", "error": "" } ``` ``` -------------------------------- ### GET /websites/paragraph Source: https://paragraph.com/docs/api-reference/posts/get-post-by-id Retrieves detailed information about a specific post by its ID. ```APIDOC ## GET /websites/paragraph ### Description Retrieves detailed information about a specific post by its ID. ### Method GET ### Endpoint /websites/paragraph ### Parameters #### Query Parameters - **id** (string) - Required - The unique identifier for the post. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **msg** (string) - Human-readable message about the response. - **error** (string) - Technical error details or error code (if applicable). #### Response Example ```json { "success": true, "msg": "", "error": "" } ``` #### Error Response (e.g., 400, 500) - **success** (boolean) - Always false for error responses. - **msg** (string) - Human-readable error message. - **error** (string) - Technical error details or error code. ``` -------------------------------- ### GET /v1/publications/domain/{domain} Source: https://paragraph.com/docs/api-reference/publications/get-publication-by-custom-domain Retrieve publication details using its custom domain. This endpoint allows you to fetch information about a specific publication by providing its associated custom domain. ```APIDOC ## GET /v1/publications/domain/{domain} ### Description Retrieve publication details using its custom domain. This endpoint allows you to fetch information about a specific publication by providing its associated custom domain. ### Method GET ### Endpoint https://public.api.paragraph.com/api/v1/publications/domain/{domain} ### Parameters #### Path Parameters - **domain** (string) - Required - Custom domain of the publication #### Query Parameters None #### Request Body None ### Request Example ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const publication = await api.getPublicationByDomain("avc.xyz") ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the publication - **name** (string) - Display name of the publication - **ownerUserId** (string) - ID of the user who owns this publication - **slug** (string) - URL-friendly identifier for the publication; accessible at paragraph.com/@[slug] - **customDomain** (string) - Custom domain configured for this publication - **summary** (string) - Brief description of the publication (max 500 characters) - **logoUrl** (string) - URL to the publication's logo image #### Response Example ```json { "id": "", "name": "", "ownerUserId": "", "slug": "", "customDomain": "", "summary": "", "logoUrl": "" } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example ```json { "success": false, "msg": "Publication not found", "error": "PUBLICATION_NOT_FOUND" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example ```json { "success": false, "msg": "Internal server error", "error": "INTERNAL_SERVER_ERROR" } ``` ``` -------------------------------- ### Get Publication by Domain (TypeScript) Source: https://paragraph.com/docs/api-reference/publications/get-publication-by-custom-domain Fetches publication details using its custom domain. This code sample utilizes the Paragraph API SDK for TypeScript. It requires the '@paragraph_xyz/sdk' package and takes the custom domain as input, returning publication details or an error if not found. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const publication = await api.getPublicationByDomain("avc.xyz") ``` -------------------------------- ### GET /v1/users/wallet/{walletAddress} Source: https://paragraph.com/docs/api-reference/users/get-user-by-wallet-address Retrieves user information by their Ethereum wallet address. This endpoint allows you to fetch details such as user ID, wallet address, avatar, publication ID, name, bio, and Farcaster profile information. ```APIDOC ## GET /v1/users/wallet/{walletAddress} ### Description Retrieves user information by their Ethereum wallet address. This endpoint allows you to fetch details such as user ID, wallet address, avatar, publication ID, name, bio, and Farcaster profile information. ### Method GET ### Endpoint https://public.api.paragraph.com/api/v1/users/wallet/{walletAddress} ### Parameters #### Path Parameters - **walletAddress** (string) - Required - Ethereum wallet address #### Query Parameters None #### Request Body None ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **id** (string) - Unique identifier for the user - **walletAddress** (string) - Wallet address of the user - **avatarUrl** (string) - URL to the user's avatar image - **publicationId** (string) - ID of the publication this user belongs to - **name** (string) - Display name of the user - **bio** (string) - Brief biography of the user (max 500 characters) - **farcaster** (object) - Farcaster profile information, if linked - **username** (string) - Farcaster username - **displayName** (string) - Farcaster display name - **fid** (number) - Farcaster fid #### Response Example ```json { "id": "", "walletAddress": "", "avatarUrl": "", "publicationId": "", "name": "", "bio": "", "farcaster": { "username": "", "displayName": "", "fid": 123 } } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (404) ```json { "success": false, "msg": "User not found", "error": "USER_NOT_FOUND" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (500) ```json { "success": false, "msg": "Internal server error", "error": "INTERNAL_SERVER_ERROR" } ``` ``` -------------------------------- ### GET /v1/coins/contract/{contractAddress} Source: https://paragraph.com/docs/api-reference/coins/get-coin-by-contract-address Retrieve information about a tokenized post using its contract address. This endpoint allows you to fetch details of a specific coin (tokenized post) by providing its unique contract address. ```APIDOC ## GET /v1/coins/contract/{contractAddress} ### Description Retrieve information about a tokenized post using its contract address. ### Method GET ### Endpoint https://public.api.paragraph.com/api/v1/coins/contract/{contractAddress} ### Parameters #### Path Parameters - **contractAddress** (string) - Required - Contract address #### Query Parameters This endpoint does not accept any query parameters. #### Request Body This endpoint does not accept a request body. ### Request Example ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const coin = await api.getCoinByContract("0xe9bb3166ff5f96381e257d509a801303b68e5d34") ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the coin - **contractAddress** (string) - Base contract address for the coin - **symbol** (string) - Token symbol - **postId** (string) - ID of the post this token is associated with #### Response Example ```json { "id": "", "contractAddress": "", "symbol": "", "postId": "" } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (404) ```json { "success": false, "msg": "", "error": "" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (500) ```json { "success": false, "msg": "", "error": "" } ``` ``` -------------------------------- ### Internal Server Error Schema Example Source: https://paragraph.com/docs/api-reference/coins/list-coin-holders-by-id Defines the expected structure for an internal server error response, including success status, a message, and an optional error string. It requires 'success' and 'msg' properties. ```yaml examples: example: value: success: true msg: error: ``` -------------------------------- ### Get User by Wallet Address (TypeScript) Source: https://paragraph.com/docs/api-reference/users/get-user-by-wallet-address This snippet demonstrates how to retrieve user details from the Paragraph API using a provided Ethereum wallet address. It utilizes the `@paragraph_xyz/sdk` library and expects an active internet connection to the Paragraph API production server. The function takes a wallet address as input and returns user data or an error. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const user = await api.getUserByWallet("0xc9ddb5E37165827BBBFf15b582E232C06862C4E8") ``` -------------------------------- ### GET /v1/coins/contract/{contractAddress}/holders Source: https://paragraph.com/docs/api-reference/coins/list-coin-holders-by-contract-address Retrieves a list of coin holders for a given contract address. Supports pagination through cursor and limit parameters. ```APIDOC ## GET /v1/coins/contract/{contractAddress}/holders ### Description Retrieves a list of coin holders for a given contract address. Supports pagination through cursor and limit parameters. ### Method GET ### Endpoint https://public.api.paragraph.com/api/v1/coins/contract/{contractAddress}/holders ### Parameters #### Path Parameters - **contractAddress** (string) - Required - Contract address #### Query Parameters - **cursor** (string) - Optional - Cursor for pagination - **limit** (integer) - Optional - Maximum number of items to return (1-100, default: 10) ### Request Body This endpoint does not accept a request body. ### Request Example (No request body example for GET request) ### Response #### Success Response (200) - **items** (array) - Array of coin holder objects, each containing walletAddress, userId, balance, and avatarUrl. - **pagination** (object) - Object containing cursor, hasMore, and total for pagination. #### Response Example ```json { "items": [ { "walletAddress": "0x1234567890abcdef1234567890abcdef12345678", "userId": "user-123", "balance": "1000000000000000000", "avatarUrl": "https://example.com/avatar.png" } ], "pagination": { "cursor": "next-cursor-string", "hasMore": true, "total": 150 } } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses. - **msg** (string) - Human-readable error message. - **error** (string) - Technical error details or error code. #### Error Response Example (404) ```json { "success": false, "msg": "Coin not found.", "error": "COIN_NOT_FOUND" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses. - **msg** (string) - Human-readable error message. - **error** (string) - Technical error details or error code. #### Error Response Example (500) ```json { "success": false, "msg": "Internal server error.", "error": "INTERNAL_SERVER_ERROR" } ``` ``` -------------------------------- ### Get Publication by ID Source: https://paragraph.com/docs/api-reference Retrieves the details of a specific publication using its unique identifier. ```APIDOC ## GET /v1/publications/{publicationId} ### Description Retrieves the details of a specific publication using its unique identifier. ### Method GET ### Endpoint /v1/publications/{publicationId} ### Parameters #### Path Parameters - **publicationId** (string) - Required - Unique identifier of the publication ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **id** (string) - Unique identifier for the publication - **name** (string) - Display name of the publication - **ownerUserId** (string) - ID of the user who owns this publication - **slug** (string) - URL-friendly identifier for the publication; accessible at paragraph.com/@[slug] - **customDomain** (string) - Custom domain configured for this publication - **summary** (string) - Brief description of the publication (max 500 characters) - **logoUrl** (string) - URL to the publication's logo image #### Response Example ```json { "id": "", "name": "", "ownerUserId": "", "slug": "", "customDomain": "", "summary": "", "logoUrl": "" } ``` ``` -------------------------------- ### GET /websites/{publication_slug}/posts/{post_slug} Source: https://paragraph.com/docs/api-reference/posts/get-post-by-publication-slug-and-post-slug Retrieves a specific post using its publication slug and post slug. This endpoint is designed to fetch detailed information about a blog post. ```APIDOC ## GET /websites/{publication_slug}/posts/{post_slug} ### Description Retrieves a specific post using its publication slug and post slug. ### Method GET ### Endpoint /websites/{publication_slug}/posts/{post_slug} ### Parameters #### Path Parameters - **publication_slug** (string) - Required - The unique identifier for the publication. - **post_slug** (string) - Required - The unique identifier for the post within the publication. ### Request Example ``` { "example": "" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **msg** (string) - A message describing the result of the request. - **post** (object) - Contains the details of the post. - **title** (string) - The title of the post. - **content** (string) - The main content of the post. - **author** (string) - The author of the post. - **published_at** (string) - The date and time the post was published. #### Response Example ```json { "success": true, "msg": "Post retrieved successfully", "post": { "title": "Example Post Title", "content": "This is the content of the example post.", "author": "John Doe", "published_at": "2023-10-27T10:00:00Z" } } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses. - **msg** (string) - Human-readable error message. - **error** (string) - Technical error details or error code. #### Response Example (404) ```json { "success": false, "msg": "Post not found", "error": "POST_NOT_FOUND" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses. - **msg** (string) - Human-readable error message. - **error** (string) - Technical error details or error code. #### Response Example (500) ```json { "success": false, "msg": "Internal server error", "error": "INTERNAL_SERVER_ERROR" } ``` ``` -------------------------------- ### GET /v1/users/{userId} Source: https://paragraph.com/docs/api-reference/users/get-user-by-id Retrieves detailed information about a specific user using their unique identifier. Supports fetching user details, wallet address, avatar, publication ID, name, bio, and Farcaster profile information if available. ```APIDOC ## GET /v1/users/{userId} ### Description Retrieves detailed information about a specific user using their unique identifier. Supports fetching user details, wallet address, avatar, publication ID, name, bio, and Farcaster profile information if available. ### Method GET ### Endpoint `/v1/users/{userId}` ### Parameters #### Path Parameters - **userId** (string) - Required - Unique identifier of the user #### Query Parameters None #### Request Body None ### Request Example ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const user = await api.getUser("AeAOtR8TqKWyzG5apA1R") ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the user - **walletAddress** (string) - Wallet address of the user - **avatarUrl** (string) - URL to the user's avatar image - **publicationId** (string) - ID of the publication this user belongs to - **name** (string) - Display name of the user - **bio** (string) - Brief biography of the user (max 500 characters) - **farcaster** (object) - Farcaster profile information, if linked - **username** (string) - Farcaster username - **displayName** (string) - Farcaster display name - **fid** (number) - Farcaster fid #### Response Example ```json { "id": "", "walletAddress": "", "avatarUrl": "", "publicationId": "", "name": "", "bio": "", "farcaster": { "username": "", "displayName": "", "fid": 123 } } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (404) ```json { "success": false, "msg": "User not found", "error": "USER_NOT_FOUND" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (500) ```json { "success": false, "msg": "Internal server error", "error": "INTERNAL_ERROR" } ``` ``` -------------------------------- ### GET /v1/publications/slug/{slug} Source: https://paragraph.com/docs/api-reference/publications/get-publication-by-slug Retrieves details of a publication using its unique URL-friendly slug. This endpoint is useful for displaying publication information on your website or application. ```APIDOC ## GET /v1/publications/slug/{slug} ### Description Retrieves details of a publication by its URL-friendly slug. This allows you to fetch specific publication data based on its identifier. ### Method GET ### Endpoint /v1/publications/slug/{slug} ### Parameters #### Path Parameters - **slug** (string) - Required - URL-friendly identifier of the publication. Max length: 256, Min length: 1. #### Query Parameters None #### Request Body None ### Request Example ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const publication = await api.getPublicationBySlug("blog") ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the publication. - **name** (string) - Display name of the publication. - **ownerUserId** (string) - ID of the user who owns this publication. - **slug** (string) - URL-friendly identifier for the publication; accessible at paragraph.com/@[slug]. - **customDomain** (string) - Custom domain configured for this publication. - **summary** (string) - Brief description of the publication (max 500 characters). - **logoUrl** (string) - URL to the publication's logo image. #### Response Example ```json { "id": "", "name": "", "ownerUserId": "", "slug": "", "customDomain": "", "summary": "", "logoUrl": "" } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses. - **msg** (string) - Human-readable error message. - **error** (string) - Technical error details or error code. #### Error Response Example (404) ```json { "success": false, "msg": "Publication not found", "error": "" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses. - **msg** (string) - Human-readable error message. - **error** (string) - Technical error details or error code. #### Error Response Example (500) ```json { "success": false, "msg": "Internal server error", "error": "" } ``` ``` -------------------------------- ### List Coin Holders with Pagination (TypeScript) Source: https://paragraph.com/docs/api-reference/coins/list-coin-holders-by-id This TypeScript code snippet demonstrates how to use the Paragraph API to retrieve a list of coin holders. It utilizes the `getCoinHolders` method and supports pagination through `limit` and `cursor` parameters. Ensure the `@paragraph_xyz/sdk` is installed. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const holders = await api.getCoinHolders("S2AlaNG5Hw0NdNptmLTw", { limit: 25, cursor: "next-cursor" }) ``` -------------------------------- ### GET /v1/publications/slug/{publicationSlug}/posts/slug/{postSlug} Source: https://paragraph.com/docs/api-reference/posts/get-post-by-publication-slug-and-post-slug Retrieves a specific post from a publication using its slug and the publication's slug. It supports an option to include the full content of the post. ```APIDOC ## GET /v1/publications/slug/{publicationSlug}/posts/slug/{postSlug} ### Description Retrieves a specific post from a publication using its slug and the publication's slug. It supports an option to include the full content of the post. ### Method GET ### Endpoint https://public.api.paragraph.com/api/v1/publications/slug/{publicationSlug}/posts/slug/{postSlug} ### Parameters #### Path Parameters - **publicationSlug** (string) - Required - URL-friendly identifier of the publication, e.g. 'blog' - **postSlug** (string) - Required - URL-friendly identifier of the post, e.g. 'my-first-post' #### Query Parameters - **includeContent** (boolean) - Optional - Include full content fields (markdown, json, staticHtml). Default: false ### Request Example ```json { "publicationSlug": "blog", "postSlug": "my-first-post" } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the post - **title** (string) - Title of the post - **imageUrl** (string) - Optional URL to the post's main image - **publishedAt** (string) - Epoch timestamp when the post was published - **updatedAt** (string) - Epoch timestamp when the post was last updated - **subtitle** (string) - Optional subtitle or brief summary - **slug** (string) - URL-friendly identifier for the post - **staticHtml** (string) - Rendered HTML content of the post - **json** (string) - TipTap JSON representation of the post content structure. - **markdown** (string) - Markdown source of the post content - **coinId** (string) - ID of the associated coin, if the post is coined #### Response Example ```json { "id": "", "title": "", "imageUrl": "", "publishedAt": "", "updatedAt": "", "subtitle": "", "slug": "", "staticHtml": "", "json": "", "markdown": "", "coinId": "" } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Error type ``` -------------------------------- ### Get Post by Publication and Post Slug (TypeScript) Source: https://paragraph.com/docs/api-reference/posts/get-post-by-publication-slug-and-post-slug Retrieves a specific post from a publication using its slug and the publication's slug. Requires the `@paragraph_xyz/sdk` package. The function takes `publicationSlug` and `postSlug` as arguments and returns a post object. ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const post = await api.getPost({ publicationSlug: "blog", postSlug: "my-first-post" }) ``` -------------------------------- ### Get Publication by ID using TypeScript Source: https://paragraph.com/docs/api-reference Retrieves publication details using the Paragraph API SDK for TypeScript. It requires an instance of ParagraphAPI and a publication ID as input. Returns publication data or an error status (200, 404, 500). ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const publication = await api.getPublication("BMV6abfvCSUl51ErCVzd") ``` -------------------------------- ### Get publication by ID Source: https://paragraph.com/docs/api-reference/publications/get-publication-by-id Retrieves detailed information about a specific publication using its unique identifier. ```APIDOC ## GET /v1/publications/{publicationId} ### Description Retrieve detailed information about a specific publication. ### Method GET ### Endpoint https://public.api.paragraph.com/api/v1/publications/{publicationId} ### Parameters #### Path Parameters - **publicationId** (string) - Required - Unique identifier of the publication #### Query Parameters None #### Request Body None ### Request Example ```typescript import { ParagraphAPI } from "@paragraph_xyz/sdk" const api = new ParagraphAPI() const publication = await api.getPublication("BMV6abfvCSUl51ErCVzd") ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the publication - **name** (string) - Display name of the publication - **ownerUserId** (string) - ID of the user who owns this publication - **slug** (string) - URL-friendly identifier for the publication; accessible at paragraph.com/@[slug] - **customDomain** (string) - Custom domain configured for this publication - **summary** (string) - Brief description of the publication (max 500 characters) - **logoUrl** (string) - URL to the publication's logo image #### Response Example ```json { "id": "", "name": "", "ownerUserId": "", "slug": "", "customDomain": "", "summary": "", "logoUrl": "" } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (404) ```json { "success": false, "msg": "", "error": "" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (500) ```json { "success": false, "msg": "", "error": "" } ``` ``` -------------------------------- ### GET /v1/publications/{publicationId}/subscribers/count Source: https://paragraph.com/docs/api-reference/publications/get-subscriber-count Retrieve the total number of subscribers for a specific publication using its unique identifier. ```APIDOC ## GET /v1/publications/{publicationId}/subscribers/count ### Description Retrieve the total number of subscribers for a publication. ### Method GET ### Endpoint /v1/publications/{publicationId}/subscribers/count ### Parameters #### Path Parameters - **publicationId** (string) - Required - Unique identifier of the publication ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **count** (number) - Total number of subscribers #### Response Example ```json { "example": "{\n \"count\": 123\n}" } ``` #### Error Response (404) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (404) ```json { "example": "{\n \"success\": false,\n \"msg\": \"Publication not found\",\n \"error\": \"PUBLICATION_NOT_FOUND\"\n}" } ``` #### Error Response (500) - **success** (boolean) - Always false for error responses - **msg** (string) - Human-readable error message - **error** (string) - Technical error details or error code #### Error Response Example (500) ```json { "example": "{\n \"success\": false,\n \"msg\": \"Internal server error\",\n \"error\": \"INTERNAL_ERROR\"\n}" } ``` ```