fluid-api-agent


Namefluid-api-agent JSON
Version 0.0.8 PyPI version JSON
download
home_pagehttps://github.com/The-Swarm-Corporation/FluidAPI
SummaryFluid API
upload_time2024-12-29 00:50:03
maintainerNone
docs_urlNone
authorKye Gomez
requires_python<4.0,>=3.10
licenseMIT
keywords artificial intelligence deep learning optimizers prompt engineering
VCS
bugtrack_url
requirements swarms loguru swarm-models asyncio aiohttp tenacity pydantic
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FluidAPI: Natural Language API Requests

[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)

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](https://github.com/kyegomez), 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](https://github.com/kyegomez/swarms), 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:

```bash
pip install fluid-api-agent
```

---

## πŸ”§ Getting Started

### Simple Example

```python
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
```python
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](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:
```env
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
```bash
git clone https://github.com/The-Swarm-Corporation/fluidapi.git
cd fluidapi
```

### Install Dependencies
```bash
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](https://github.com/kyegomez/swarms).

---

# 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](https://github.com/The-Swarm-Corporation/fluidapi/blob/main/LICENSE) file for details.

---

## 🌍 Connect with Us

- **Author**: [Kye Gomez](https://github.com/kyegomez)
- **Project**: [The-Swarm-Corporation/FluidAPI](https://github.com/The-Swarm-Corporation/fluidapi)
- **Pip Package**: [fluid-api](https://pypi.org/project/fluid-api/)

---

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/The-Swarm-Corporation/FluidAPI",
    "name": "fluid-api-agent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, optimizers, Prompt Engineering",
    "author": "Kye Gomez",
    "author_email": "kye@apac.ai",
    "download_url": "https://files.pythonhosted.org/packages/c8/4d/fe9cf40211e29bed292ba31c7d22e02fe8c14aa9f05131f12a32b187fe90/fluid_api_agent-0.0.8.tar.gz",
    "platform": null,
    "description": "# FluidAPI: Natural Language API Requests\n\n[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)\n\nWelcome to **FluidAPI**, a revolutionary framework that allows you to interact with APIs using **natural language**. No more JSON, headers, or complex formats\u2014simply describe your request in plain English, and FluidAPI will do the rest.\n\nPowered by the **Swarms Framework** and created by [Kye Gomez](https://github.com/kyegomez), FluidAPI redefines how developers interact with APIs.\n\n---\n\n## \ud83c\udf1f Features\n\n- **Natural Language API Requests**: Just describe your task, and FluidAPI generates and executes the request for you.\n- **Powered by AI Agents**: Built on the robust [Swarms Framework](https://github.com/kyegomez/swarms), enabling dynamic and intelligent API handling.\n- **Effortless Integration**: Replace complex API workflows with simple, human-friendly commands.\n- **Retry and Reliability**: Automatic retries and error handling for seamless performance.\n- **Dynamic Authentication**: Handles token management and injects them automatically.\n\n---\n\n## \ud83d\ude80 Installation\n\nInstall the `fluid-api-agent` package via pip:\n\n```bash\npip install fluid-api-agent\n```\n\n---\n\n## \ud83d\udd27 Getting Started\n\n### Simple Example\n\n```python\nfrom fluid_api_agent.main import (\n    fluid_api_request,\n)\n\n# Example 1: Basic API Request\nbasic_request = fluid_api_request(\n    \"Generate an API request to get a random cat fact from https://catfact.ninja/fact\"\n)\n\nprint(basic_request.model_dump_json(indent=4))\n```\n\n### Advanced Example\n```python\nfrom fluid_api_agent.main import (\n    fluid_api_request,\n    batch_fluid_api_request,\n)\n\n# Example 1: Basic API Request\n# Make a simple API request with default parameters\nbasic_request = fluid_api_request(\n    \"Generate an API request to get a random cat fact from https://catfact.ninja/fact\"\n)\nprint(\"\\n=== Basic Request ===\")\nprint(basic_request.model_dump_json(indent=4))\n\n# Example 2: Request with Raw Response\n# Get the raw response without any processing\nraw_request = fluid_api_request(\n    \"Generate an API request to get a random joke from https://official-joke-api.appspot.com/random_joke\",\n    return_raw=True\n)\nprint(\"\\n=== Raw Request ===\") \nprint(raw_request.model_dump_json(indent=4))\n\n# Example 3: Verbose Request\n# Enable detailed logging during request processing\nverbose_request = fluid_api_request(\n    \"Generate an API request to get weather data for New York from OpenWeatherMap\",\n    verbose=True\n)\nprint(\"\\n=== Verbose Request ===\")\nprint(verbose_request.model_dump_json(indent=4))\n\n# Example 4: Request with Custom Documentation\n# Provide API documentation to improve request generation\ndocs = \"\"\"\nAPI Endpoint: https://api.example.com/v1/users\nMethods: GET, POST\nAuthentication: Bearer token required\n\"\"\"\ncustom_doc_request = fluid_api_request(\n    \"Generate a request to get all users\",\n    documentation=docs,\n    verbose=True\n)\nprint(\"\\n=== Request with Documentation ===\")\nprint(custom_doc_request.model_dump_json(indent=4))\n\n# Example 5: Batch Processing\n# Process multiple API requests in sequence\nprint(\"\\n=== Batch Request ===\")\nbatch_results = batch_fluid_api_request(\n    tasks=[\n        \"Generate an API request to get a random dog fact from https://dogapi.dog/api/v2/facts\",\n        \"Generate an API request to get a random quote from https://api.quotable.io/random\",\n        \"Generate an API request to get Bitcoin price from CoinGecko public API\"\n    ],\n    verbose=True\n)\nfor i, result in enumerate(batch_results, 1):\n    print(f\"\\nBatch Result {i}:\")\n    print(result.model_dump_json(indent=4))\n\n```\n\n\n\nFluidAPI will:\n1. Interpret your request.\n2. Generate and execute the appropriate API call.\n3. Return the API's response.\n\n---\n\n### Example\nSee the [example.py](example.py) file for more examples.\n\n---\n\n## \u2699\ufe0f Configuration\n\n### Environment Variables\nFluidAPI uses environment variables for sensitive data:\n- `OPENAI_API_KEY`: Your OpenAI API key.\n\nSet these variables in your `.env` file:\n```env\nOPENAI_API_KEY=your-openai-api-key\nWORKSPACE_DIR=\"agent_workspace\"\n\n```\n\n---\n\n## \ud83d\udce6 Advanced Features\n\n### Retry Logic\nFluidAPI includes built-in retry logic to handle transient failures automatically. You can configure retry settings directly in the agent.\n\n### Caching\nFrequent requests are optimized with caching to improve performance.\n\n---\n\n## \ud83d\udee0 Development\n\n### Clone the Repository\n```bash\ngit clone https://github.com/The-Swarm-Corporation/fluidapi.git\ncd fluidapi\n```\n\n### Install Dependencies\n```bash\npip install -r requirements.txt\n```\n\n---\n\n## \ud83d\udca1 How It Works\n\nFluidAPI leverages the **Swarms Framework** to:\n1. Parse natural language instructions.\n2. Dynamically construct API requests.\n3. Execute requests and handle responses intelligently.\n\nLearn more about the Swarms Framework [here](https://github.com/kyegomez/swarms).\n\n---\n\n# Todo\n- [ ] Add documentation\n- [ ] Add tests\n- [ ] Add examples\n\n----\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! To get started:\n1. Fork the repository.\n2. Create a new branch.\n3. Submit a pull request.\n\n---\n\n## \ud83d\udcdd License\n\nFluidAPI is licensed under the MIT License. See the [LICENSE](https://github.com/The-Swarm-Corporation/fluidapi/blob/main/LICENSE) file for details.\n\n---\n\n## \ud83c\udf0d Connect with Us\n\n- **Author**: [Kye Gomez](https://github.com/kyegomez)\n- **Project**: [The-Swarm-Corporation/FluidAPI](https://github.com/The-Swarm-Corporation/fluidapi)\n- **Pip Package**: [fluid-api](https://pypi.org/project/fluid-api/)\n\n---\n\n**Transform the way you interact with APIs. With FluidAPI, it's as simple as saying what you want.**\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Fluid API",
    "version": "0.0.8",
    "project_urls": {
        "Documentation": "https://github.com/The-Swarm-Corporation/FluidAPI",
        "Homepage": "https://github.com/The-Swarm-Corporation/FluidAPI",
        "Repository": "https://github.com/The-Swarm-Corporation/FluidAPI"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " optimizers",
        " prompt engineering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc038534d727c9f85204d8ac85e916ee75c9675cf434f1feaf5f32873a545e93",
                "md5": "f4d3e4c7433c8cd87cd18b2e9f2ec9f7",
                "sha256": "ff8103e633746d743f4fc94a2c4dca227c205ec286c48a12acd4ba8eb39caa30"
            },
            "downloads": -1,
            "filename": "fluid_api_agent-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4d3e4c7433c8cd87cd18b2e9f2ec9f7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 8490,
            "upload_time": "2024-12-29T00:50:01",
            "upload_time_iso_8601": "2024-12-29T00:50:01.444455Z",
            "url": "https://files.pythonhosted.org/packages/bc/03/8534d727c9f85204d8ac85e916ee75c9675cf434f1feaf5f32873a545e93/fluid_api_agent-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c84dfe9cf40211e29bed292ba31c7d22e02fe8c14aa9f05131f12a32b187fe90",
                "md5": "7dae0779e61ccdc655c9e93cc22da98e",
                "sha256": "8cbb1816194d6247b777403428c39b68fa9eb7c23982c56ab5e4526d7c2c6b94"
            },
            "downloads": -1,
            "filename": "fluid_api_agent-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "7dae0779e61ccdc655c9e93cc22da98e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 8032,
            "upload_time": "2024-12-29T00:50:03",
            "upload_time_iso_8601": "2024-12-29T00:50:03.608325Z",
            "url": "https://files.pythonhosted.org/packages/c8/4d/fe9cf40211e29bed292ba31c7d22e02fe8c14aa9f05131f12a32b187fe90/fluid_api_agent-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-29 00:50:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "The-Swarm-Corporation",
    "github_project": "FluidAPI",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "swarms",
            "specs": []
        },
        {
            "name": "loguru",
            "specs": []
        },
        {
            "name": "swarm-models",
            "specs": []
        },
        {
            "name": "asyncio",
            "specs": []
        },
        {
            "name": "aiohttp",
            "specs": []
        },
        {
            "name": "tenacity",
            "specs": []
        },
        {
            "name": "pydantic",
            "specs": []
        }
    ],
    "lcname": "fluid-api-agent"
}
        
Elapsed time: 0.43273s