API Code Examples

API Code Examples

This section provides examples of how to interact with the Meme Token Generator API using different programming languages and frameworks.

cURL Example

Here are several ways to use cURL to interact with the API:

Basic Request

curl -X POST \
  https://ai.justpump.pro \
  -H 'Content-Type: application/json' \
  -d '{
    "userDescription": "A token based on flying pandas eating bamboo in space"
  }'

Save Response to File

curl -X POST \
  https://ai.justpump.pro \
  -H 'Content-Type: application/json' \
  -d '{
    "userDescription": "A token based on flying pandas eating bamboo in space"
  }' \
  -o response.json

With Pretty Printing

Windows Command Prompt

With Verbose Output

Example Response

Notes for cURL Usage

  1. Make sure to properly escape quotes in the JSON payload

  2. Use -v flag for debugging and seeing detailed request/response information

  3. Windows users should use ^ instead of \ for line continuation

  4. The -o flag can be used to save the response to a file

  5. Use json_pp or jq for prettier JSON output formatting

JavaScript / Node.js Example

Using the native fetch API to make requests to the endpoint.

Python Example

Using the requests library to interact with the API.

React/TypeScript Component Example

A complete React component with TypeScript support and error handling.

Example Response

Here's what a successful response looks like:

Error Handling

All examples include proper error handling for common scenarios:

  • Network errors

  • Invalid responses

  • API errors

  • Validation errors

Make sure to implement appropriate error handling in your production code.

Dependencies

  • Python: requests libraryExample Usage

    cURL

    JavaScript

    Python

    Error Handling

  • React: react and typescript

  • Node.js: No additional dependencies needed

Notes

  1. All examples assume you have the necessary dependencies installed

  2. ded for better development experience

  3. Examples include basic error handling and loading states

  4. All requests use the POST method with JSON content type

Additional Resources

Last updated