Metadata-Version: 2.5
Name: semantic-kernel-datacircle
Version: 0.1.0
Summary: A Semantic Kernel plugin for the Datacircle API: find the best GTM APIs
Project-URL: Homepage, https://datacircle.dev
Project-URL: Documentation, https://api.datacircle.dev/v1/openapi.json
Project-URL: Repository, https://github.com/waynehamadi/semantic-kernel-datacircle
License-Expression: MIT
License-File: LICENSE
Keywords: agents,api,api-pricing,b2b-data,datacircle,gtm,kernel-function,plugin,semantic-kernel,semantic-kernel-plugin,tools
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: requests>=2.25
Requires-Dist: semantic-kernel>=1.29
Description-Content-Type: text/markdown

# semantic-kernel-datacircle

Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website: https://datacircle.dev

This package is a [Semantic Kernel](https://github.com/microsoft/semantic-kernel) plugin on Datacircle's open API, https://api.datacircle.dev/v1. You need no key and no account.

```bash
pip install semantic-kernel-datacircle
```

| Function | What it gives | Call |
| --- | --- | --- |
| `list_apis` | Every GTM API on Datacircle, with its slug, number of plans and providers, and its best plan | `GET /apis` |
| `best_plans` | One API's plans, best first by score out of 100, each with its rank and price per 1,000 calls | `GET /apis/{slug}/best` |
| `search_plans` | Plans by provider or plan name, on every API or one, sorted by score, provider or price | `GET /plans` |
| `provider` | The APIs a provider sells and its rank on each | `GET /providers/{slug}` |

## Use

With an agent:

```python
import asyncio

from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel_datacircle import DatacirclePlugin

agent = ChatCompletionAgent(
    service=OpenAIChatCompletion(),
    name="GTMAssistant",
    instructions="Answer from the Datacircle functions.",
    plugins=[DatacirclePlugin()],
)


async def main():
    response = await agent.get_response(messages="Which email finder API is best for under $5 per 1,000?")
    print(response)


asyncio.run(main())
```

Or on a kernel, with auto function calling:

```python
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.functions import KernelArguments
from semantic_kernel_datacircle import DatacirclePlugin

kernel = Kernel()
kernel.add_service(OpenAIChatCompletion())
kernel.add_plugin(DatacirclePlugin(), plugin_name="datacircle")

settings = OpenAIChatPromptExecutionSettings(function_choice_behavior=FunctionChoiceBehavior.Auto())
result = await kernel.invoke_prompt("Who sells the cheapest Hunter plan?", arguments=KernelArguments(settings=settings))
```

Any chat completion service with function calling works. Each function is a `@kernel_function` that gives the model the API's answer as JSON. A function can also be called through the kernel itself:

```python
await kernel.invoke(plugin_name="datacircle", function_name="best_plans", arguments=KernelArguments(slug="email-finder", limit=3))
```

or as a plain function that gives a dict:

```python
from semantic_kernel_datacircle import best_plans

best_plans(slug="email-finder", limit=3)
```

Each plan comes with its rank, provider, plan, score, price per 1,000 (`perThousand`, in dollars) and its page on datacircle.dev, which lists every field. An unknown slug or a value out of range comes back as `{"error": ...}` with the API's words (an unknown API's answer lists every slug), so the model can call again.

## Network

Each call makes one HTTPS GET to https://api.datacircle.dev/v1 with the function's arguments and nothing else. The API takes up to 60 calls a minute from one address; the functions wait once, a minute at most, when it asks them to. `DatacirclePlugin(timeout=10)` sets how long a call may take. Every plan is also one file at https://datacircle.dev/datacircle.json.

## Links

- Datacircle: https://datacircle.dev
- The API: https://datacircle.dev/api
- Its spec: https://api.datacircle.dev/v1/openapi.json
- What each key means: https://datacircle.dev/fields

MIT license.
