Skip to main content

Fluid API

Project description

FluidAPI: Natural Language API Requests

Join our Discord Subscribe on YouTube Connect on LinkedIn Follow on X.com

Welcome to FluidAPI, a revolutionary framework that allows you to interact with APIs using natural language. No more JSON, headers, or complex formats—simply describe your request in plain English, and FluidAPI will do the rest.

Powered by the Swarms Framework and created by Kye Gomez, FluidAPI redefines how developers interact with APIs.


🌟 Features

  • Natural Language API Requests: Just describe your task, and FluidAPI generates and executes the request for you.
  • Powered by AI Agents: Built on the robust Swarms Framework, enabling dynamic and intelligent API handling.
  • Effortless Integration: Replace complex API workflows with simple, human-friendly commands.
  • Retry and Reliability: Automatic retries and error handling for seamless performance.
  • Dynamic Authentication: Handles token management and injects them automatically.

🚀 Installation

Install the fluid-api-agent package via pip:

pip install fluid-api-agent

🔧 Getting Started

Simple Example

from fluid_api_agent.main import (
    fluid_api_request,
)

# Example 1: Basic API Request
basic_request = fluid_api_request(
    "Generate an API request to get a random cat fact from https://catfact.ninja/fact"
)

print(basic_request.model_dump_json(indent=4))

Advanced Example

from fluid_api_agent.main import (
    fluid_api_request,
    batch_fluid_api_request,
)

# Example 1: Basic API Request
# Make a simple API request with default parameters
basic_request = fluid_api_request(
    "Generate an API request to get a random cat fact from https://catfact.ninja/fact"
)
print("\n=== Basic Request ===")
print(basic_request.model_dump_json(indent=4))

# Example 2: Request with Raw Response
# Get the raw response without any processing
raw_request = fluid_api_request(
    "Generate an API request to get a random joke from https://official-joke-api.appspot.com/random_joke",
    return_raw=True
)
print("\n=== Raw Request ===") 
print(raw_request.model_dump_json(indent=4))

# Example 3: Verbose Request
# Enable detailed logging during request processing
verbose_request = fluid_api_request(
    "Generate an API request to get weather data for New York from OpenWeatherMap",
    verbose=True
)
print("\n=== Verbose Request ===")
print(verbose_request.model_dump_json(indent=4))

# Example 4: Request with Custom Documentation
# Provide API documentation to improve request generation
docs = """
API Endpoint: https://api.example.com/v1/users
Methods: GET, POST
Authentication: Bearer token required
"""
custom_doc_request = fluid_api_request(
    "Generate a request to get all users",
    documentation=docs,
    verbose=True
)
print("\n=== Request with Documentation ===")
print(custom_doc_request.model_dump_json(indent=4))

# Example 5: Batch Processing
# Process multiple API requests in sequence
print("\n=== Batch Request ===")
batch_results = batch_fluid_api_request(
    tasks=[
        "Generate an API request to get a random dog fact from https://dogapi.dog/api/v2/facts",
        "Generate an API request to get a random quote from https://api.quotable.io/random",
        "Generate an API request to get Bitcoin price from CoinGecko public API"
    ],
    verbose=True
)
for i, result in enumerate(batch_results, 1):
    print(f"\nBatch Result {i}:")
    print(result.model_dump_json(indent=4))

FluidAPI will:

  1. Interpret your request.
  2. Generate and execute the appropriate API call.
  3. Return the API's response.

Example

See the example.py file for more examples.


⚙️ Configuration

Environment Variables

FluidAPI uses environment variables for sensitive data:

  • OPENAI_API_KEY: Your OpenAI API key.

Set these variables in your .env file:

OPENAI_API_KEY=your-openai-api-key
WORKSPACE_DIR="agent_workspace"

📦 Advanced Features

Retry Logic

FluidAPI includes built-in retry logic to handle transient failures automatically. You can configure retry settings directly in the agent.

Caching

Frequent requests are optimized with caching to improve performance.


🛠 Development

Clone the Repository

git clone https://github.com/The-Swarm-Corporation/fluidapi.git
cd fluidapi

Install Dependencies

pip install -r requirements.txt

💡 How It Works

FluidAPI leverages the Swarms Framework to:

  1. Parse natural language instructions.
  2. Dynamically construct API requests.
  3. Execute requests and handle responses intelligently.

Learn more about the Swarms Framework here.


Todo

  • Add documentation
  • Add tests
  • Add examples

🤝 Contributing

We welcome contributions! To get started:

  1. Fork the repository.
  2. Create a new branch.
  3. Submit a pull request.

📝 License

FluidAPI is licensed under the MIT License. See the LICENSE file for details.


🌍 Connect with Us


Transform the way you interact with APIs. With FluidAPI, it's as simple as saying what you want.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluid_api_agent-0.0.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluid_api_agent-0.0.5-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file fluid_api_agent-0.0.5.tar.gz.

File metadata

  • Download URL: fluid_api_agent-0.0.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.3.0

File hashes

Hashes for fluid_api_agent-0.0.5.tar.gz
Algorithm Hash digest
SHA256 4ba3a4e1384637a4b8bcb7df943a11e656e81e71442da124b62ed616593e891d
MD5 6a29e68fedaa7d573be434acc5b0546f
BLAKE2b-256 2eb03eeef24649f592477003ab9bf23bbcaa5690209fed333562d6db301b5080

See more details on using hashes here.

File details

Details for the file fluid_api_agent-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: fluid_api_agent-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.3.0

File hashes

Hashes for fluid_api_agent-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e5e4997c7ccbab14422cad41a1b85defcb9d0f387e7819990ee2112cc063ca62
MD5 bfceb708439d6ded8c4e44e25d2b888c
BLAKE2b-256 be3a1acda0a61d516215c2acb9888cf57a93d9a1e61d273073ad16e26d8d4b38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page