magentic-datacircle 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ """Functions for magentic on Datacircle's open API (https://api.datacircle.dev/v1): find the best GTM APIs, no key."""
2
+
3
+ from magentic_datacircle._api import BASE_URL, DatacircleError
4
+ from magentic_datacircle.tools import (
5
+ ASYNC_FUNCTIONS,
6
+ FUNCTIONS,
7
+ TOOL_NAMES,
8
+ arun,
9
+ datacircle_async_functions,
10
+ datacircle_best_plans,
11
+ datacircle_functions,
12
+ datacircle_list_apis,
13
+ datacircle_provider,
14
+ datacircle_search_plans,
15
+ run,
16
+ )
17
+
18
+ __version__ = "0.1.0"
19
+ __all__ = ["ASYNC_FUNCTIONS", "BASE_URL", "DatacircleError", "FUNCTIONS", "TOOL_NAMES", "arun", "datacircle_async_functions",
20
+ "datacircle_best_plans", "datacircle_functions", "datacircle_list_apis", "datacircle_provider",
21
+ "datacircle_search_plans", "run"]
@@ -0,0 +1,101 @@
1
+ """One HTTPS GET to Datacircle's open API (https://api.datacircle.dev/v1), no key, and what its answers are cut to for a model."""
2
+
3
+ import json
4
+ import math
5
+ import re
6
+ import time
7
+ import unicodedata
8
+ import urllib.error
9
+ import urllib.parse
10
+ import urllib.request
11
+ from typing import Any, Dict, List, Optional
12
+
13
+ BASE_URL = "https://api.datacircle.dev/v1"
14
+ TIMEOUT = 30.0
15
+ USER_AGENT = "magentic-datacircle/0.1.0"
16
+
17
+ # A plan holds about 90 keys (its terms of use, its aggregators...): the tools keep the ones that choose a plan, the rest is on its page.
18
+ PLAN_KEYS = ["api", "rank", "provider", "plan", "score", "perThousand", "notFoundPerThousand", "billing", "pay",
19
+ "currency", "units", "unit", "strengths", "latencyMs", "page", "pricingPage", "docs"]
20
+ API_KEYS = ["api", "slug", "plans", "providers", "best", "bestPage", "sheetPage"]
21
+
22
+
23
+ class DatacircleError(Exception):
24
+ """The API's refusal in its own words, why it could not be reached, or an argument it can't take: a tool gives the
25
+ model its words as its JSON text, {"error": ...}. status is the API's HTTP status, None when it gave none;
26
+ retryable, whether the same call may be answered later (the API out of reach, busy or failing)."""
27
+
28
+ def __init__(self, message: str, status: Optional[int] = None, retryable: bool = False):
29
+ super().__init__(message)
30
+ self.status = status
31
+ self.retryable = retryable
32
+
33
+
34
+ def brief(item: Dict[str, Any], keys: List[str] = PLAN_KEYS) -> Dict[str, Any]:
35
+ return {key: item[key] for key in keys if item.get(key) is not None}
36
+
37
+
38
+ def slug(value: Any) -> str:
39
+ """The API's rule for a slug: the name in lowercase letters and digits, the rest a hyphen."""
40
+ plain = unicodedata.normalize("NFKD", str(value or "").strip().lower())
41
+ plain = "".join(char for char in plain if not unicodedata.combining(char))
42
+ return re.sub(r"[^a-z0-9]+", "-", plain).strip("-")
43
+
44
+
45
+ def whole(name: str, value: Any, low: int, high: Optional[int] = None) -> Optional[int]:
46
+ """A whole number from low to high, or None when left out: a plain call may send one as text."""
47
+ if value is None or value == "":
48
+ return None
49
+ try:
50
+ number = float(value)
51
+ except (TypeError, ValueError):
52
+ number = float("nan")
53
+ if isinstance(value, bool) or not math.isfinite(number) or number != int(number):
54
+ raise DatacircleError(f"{name} must be a whole number, not {value!r}")
55
+ if number < low or (high is not None and number > high):
56
+ raise DatacircleError(f"{name} must be from {low} to {high}, not {int(number)}" if high is not None
57
+ else f"{name} must be {low} or more, not {int(number)}")
58
+ return int(number)
59
+
60
+
61
+ def _words(body: bytes) -> str:
62
+ """A refusal's words: the API's error, with every slug when the slug was unknown."""
63
+ text = body.decode("utf-8", "replace")
64
+ try:
65
+ parsed = json.loads(text)
66
+ if parsed.get("slugs"):
67
+ return f"{parsed['error']}; the slugs: {', '.join(parsed['slugs'])}"
68
+ return str(parsed.get("error", text))
69
+ except (ValueError, KeyError, TypeError, AttributeError):
70
+ return text
71
+
72
+
73
+ def get(path: str, params: Optional[Dict[str, Any]] = None) -> Any:
74
+ """The API's JSON answer, or a DatacircleError with its words: waits once when it answers 429."""
75
+ query = urllib.parse.urlencode({key: value for key, value in (params or {}).items() if value not in (None, "")})
76
+ url = f"{BASE_URL.rstrip('/')}{path}" + (f"?{query}" if query else "")
77
+ request = urllib.request.Request(url, headers={"Accept": "application/json", "User-Agent": USER_AGENT})
78
+ for attempt in range(2):
79
+ try:
80
+ with urllib.request.urlopen(request, timeout=TIMEOUT) as answer:
81
+ body = answer.read()
82
+ except urllib.error.HTTPError as error:
83
+ body = error.read()
84
+ if error.code == 429 and not attempt:
85
+ try:
86
+ wait = int(error.headers.get("Retry-After") or 30)
87
+ except ValueError:
88
+ wait = 30
89
+ time.sleep(min(max(wait, 1), 60))
90
+ continue
91
+ if error.code == 429:
92
+ raise DatacircleError("Datacircle's API answered 429 twice: wait a minute and call again", 429, True) from None
93
+ raise DatacircleError(f"Datacircle's API answered {error.code}: {_words(body)[:3000]}", error.code,
94
+ error.code >= 500) from None
95
+ except (urllib.error.URLError, OSError) as error:
96
+ raise DatacircleError(f"Datacircle's API could not be reached: {getattr(error, 'reason', error)}",
97
+ retryable=True) from None
98
+ try:
99
+ return json.loads(body)
100
+ except ValueError as error:
101
+ raise DatacircleError(f"Datacircle's API gave no JSON: {error}") from None
File without changes
@@ -0,0 +1,185 @@
1
+ """Functions for magentic on Datacircle's open API, https://api.datacircle.dev/v1: no key, no account.
2
+
3
+ magentic makes a function's schema from the function itself: its name, its docstring as the description, and each
4
+ argument's type and description from its Annotated Field. Each function goes in @prompt(functions=[...]),
5
+ @prompt_chain(functions=[...]) and @chatprompt(functions=[...]) beside an app's own, on each of magentic's chat models.
6
+ A function makes one HTTPS GET and returns the API's answer as JSON text, which magentic gives the model as it is on
7
+ every backend: a dict would go to Anthropic as an object, where a tool result takes text or blocks. A refusal (an
8
+ unknown slug, an argument out of range, the API out of reach) is the JSON text {"error": the API's words}, never an
9
+ exception: magentic raises a function's exception out of the prompt, which ends the chain.
10
+
11
+ The async functions have the same names, docstrings and arguments, and run the GET in a thread, so an async prompt's
12
+ parallel calls run at once and its event loop is never held.
13
+ """
14
+
15
+ import asyncio
16
+ import functools
17
+ import json
18
+ import urllib.parse
19
+ from typing import Annotated, Any, Awaitable, Callable, Dict, List, Mapping, Optional, Sequence
20
+
21
+ from pydantic import Field
22
+
23
+ from magentic_datacircle import _api
24
+
25
+
26
+ def _text(function: Callable[..., Dict[str, Any]], *args: Any) -> str:
27
+ """What a function gives the model: its answer as JSON text, or {"error": ...} when the API or its checks refused."""
28
+ try:
29
+ answer = function(*args)
30
+ except _api.DatacircleError as error:
31
+ answer = {"error": str(error)}
32
+ return json.dumps(answer, ensure_ascii=False)
33
+
34
+
35
+ def _best(plans: Any) -> Optional[Dict[str, Any]]:
36
+ """A provider's best plan on an API: its lowest rank, a plan with no score having none."""
37
+ ranked = sorted(plans, key=lambda plan: plan.get("rank") if isinstance(plan.get("rank"), (int, float)) else float("inf"))
38
+ return _api.brief(ranked[0], ["plan", "score", "perThousand", "page"]) if ranked else None
39
+
40
+
41
+ def _list_apis(query: Any, limit: Any) -> Dict[str, Any]:
42
+ count = _api.whole("limit", limit, 1, 200) or 20
43
+ apis = _api.get("/apis")
44
+ words = [word for word in str(query or "").lower().replace("-", " ").split() if word]
45
+ held = []
46
+ for index, api in enumerate(apis):
47
+ name = f"{api.get('api', '')} {str(api.get('slug', '')).replace('-', ' ')}".lower()
48
+ matched = sum(word in name for word in words)
49
+ if matched or not words:
50
+ held.append((-matched, index, api))
51
+ found = [_api.brief(api, _api.API_KEYS) for _, _, api in sorted(held, key=lambda h: h[:2])]
52
+ return {"total": len(found), "apis": found[:count]}
53
+
54
+
55
+ def _best_plans(slug: Any, limit: Any) -> Dict[str, Any]:
56
+ made = _api.slug(slug)
57
+ if not made:
58
+ raise _api.DatacircleError("Give an API's slug, like 'email-finder': datacircle_list_apis gives every slug")
59
+ answer = _api.get(f"/apis/{urllib.parse.quote(made)}/best", {"limit": _api.whole("limit", limit, 1, 50)})
60
+ return {**answer, "plans": [_api.brief(plan) for plan in answer.get("plans") or []]}
61
+
62
+
63
+ def _search_plans(api: Any, query: Any, sort: Any, limit: Any, offset: Any) -> Dict[str, Any]:
64
+ order = str(sort).strip().lower() if sort not in (None, "") else None
65
+ if order is not None and order not in ("score", "provider", "price"):
66
+ raise _api.DatacircleError(f"sort must be score, provider or price, not {sort!r}")
67
+ params = {"api": api, "query": query, "sort": order, "limit": _api.whole("limit", limit, 1, 50),
68
+ "offset": _api.whole("offset", offset, 0)}
69
+ answer = _api.get("/plans", params)
70
+ return {**answer, "plans": [_api.brief(plan) for plan in answer.get("plans") or []]}
71
+
72
+
73
+ def _provider(slug: Any) -> Dict[str, Any]:
74
+ made = _api.slug(slug)
75
+ if not made:
76
+ raise _api.DatacircleError("Give a provider's slug or name, like 'bright-data' or 'Bright Data'")
77
+ answer = _api.get(f"/providers/{urllib.parse.quote(made)}")
78
+ apis = [{**_api.brief(entry, ["api", "slug", "rank", "bestPage"]), "plans": len(entry.get("plans") or []),
79
+ "best": _best(entry.get("plans") or [])} for entry in answer.get("apis") or []]
80
+ return {**answer, "apis": apis}
81
+
82
+
83
+ # The functions. A number has no bounds in its schema and sort is a str, not a Literal: magentic raises a schema's
84
+ # refusal out of the prompt, where the function's own check gives the model its words and the chain goes on.
85
+
86
+ def datacircle_list_apis(
87
+ query: Annotated[Optional[str], Field(description="Words of the API's name or slug, like 'email' or 'linkedin profile'. The APIs that hold the most of them come first, in the sheet's order when left out.")] = None,
88
+ limit: Annotated[Optional[int], Field(description="How many APIs to give, 1 to 200. 20 when left out, of about 170.")] = None,
89
+ ) -> str:
90
+ """Lists the GTM APIs on Datacircle's sheet (https://datacircle.dev), with each API's slug, how many plans and providers it has and its best plan. Call it to find an API's slug when you don't know it. Gives JSON: total, the APIs found, and apis, each with api, slug, plans, providers and best. Or {"error": ...} in the API's words."""
91
+ return _text(_list_apis, query, limit)
92
+
93
+
94
+ def datacircle_best_plans(
95
+ slug: Annotated[str, Field(description="The API's slug, like 'email-finder' or 'linkedin-profile', as datacircle_list_apis gives it.")],
96
+ limit: Annotated[Optional[int], Field(description="How many plans to give, 1 to 50. 10 when left out.")] = None,
97
+ ) -> str:
98
+ """Gives an API's plans best first by their score out of 100 on Datacircle's benchmark (https://datacircle.dev): the best providers of an API. Gives JSON: api, slug, total and plans, each with rank, provider, plan, score, perThousand (a plan's price of 1,000 items in dollars), pay (the plan's whole price in its currency) and page. Or {"error": ...} in the API's words."""
99
+ return _text(_best_plans, slug, limit)
100
+
101
+
102
+ def datacircle_search_plans(
103
+ api: Annotated[Optional[str], Field(description="Only this API's plans, by its name or slug, like 'email-finder'. A provider's name goes in query, never here. Every API when left out.")] = None,
104
+ query: Annotated[Optional[str], Field(description="Words that must all appear in the provider's or plan's name, like 'bright data'.")] = None,
105
+ sort: Annotated[Optional[str], Field(description="score (best first, the default), provider (A to Z) or price ($ per 1,000, lowest first).")] = None,
106
+ limit: Annotated[Optional[int], Field(description="How many plans to give, 1 to 50. 10 when left out.")] = None,
107
+ offset: Annotated[Optional[int], Field(description="How many found plans to skip first. 0 when left out.")] = None,
108
+ ) -> str:
109
+ """Searches every plan on Datacircle's sheet (https://datacircle.dev), or one API's, by provider or plan name, sorted by score, provider or price. Gives JSON: total, the plans found, offset and plans, each with api, rank, provider, plan, score, perThousand (a plan's price of 1,000 items in dollars), pay and page. Or {"error": ...} in the API's words."""
110
+ return _text(_search_plans, api, query, sort, limit, offset)
111
+
112
+
113
+ def datacircle_provider(
114
+ slug: Annotated[str, Field(description="The provider's slug, like 'bright-data', or its name, like 'Bright Data', which is made a slug.")],
115
+ ) -> str:
116
+ """Gives each API one provider sells and its rank on each on Datacircle's benchmark (https://datacircle.dev), with its best plan there. Gives JSON: provider, slug, website and apis, each with api, slug, rank, plans (how many it has there) and best, its best plan there. Or {"error": ...} in the API's words."""
117
+ return _text(_provider, slug)
118
+
119
+
120
+ def _in_thread(function: Callable[..., str]) -> Callable[..., Awaitable[str]]:
121
+ """The async function of a function: the same name, docstring and signature (inspect follows __wrapped__), its GET in a thread."""
122
+ @functools.wraps(function)
123
+ async def run_in_thread(*args: Any, **kwargs: Any) -> str:
124
+ return await asyncio.to_thread(function, *args, **kwargs)
125
+ return run_in_thread
126
+
127
+
128
+ FUNCTIONS: Dict[str, Callable[..., str]] = {function.__name__: function for function in (
129
+ datacircle_list_apis, datacircle_best_plans, datacircle_search_plans, datacircle_provider)}
130
+ ASYNC_FUNCTIONS: Dict[str, Callable[..., Awaitable[str]]] = {name: _in_thread(function) for name, function in FUNCTIONS.items()}
131
+ TOOL_NAMES = list(FUNCTIONS)
132
+ _ARGUMENTS = {"datacircle_list_apis": ("query", "limit"), "datacircle_best_plans": ("slug", "limit"),
133
+ "datacircle_search_plans": ("api", "query", "sort", "limit", "offset"),
134
+ "datacircle_provider": ("slug",)}
135
+
136
+
137
+ def _names(tool_names: Optional[Sequence[str]]) -> List[str]:
138
+ if isinstance(tool_names, str):
139
+ raise TypeError("tool_names is a list of names, like ['datacircle_best_plans']")
140
+ for name in tool_names or []:
141
+ if name not in FUNCTIONS:
142
+ raise ValueError(f"Datacircle has no function {name!r}: its functions are {', '.join(TOOL_NAMES)}")
143
+ return list(TOOL_NAMES if tool_names is None else tool_names)
144
+
145
+
146
+ def datacircle_functions(tool_names: Optional[Sequence[str]] = None) -> List[Callable[..., str]]:
147
+ """The functions, for @prompt(..., functions=datacircle_functions()), @prompt_chain or @chatprompt, or beside one's
148
+ own: functions=[*datacircle_functions(), my_function]. tool_names keeps some of them only, in their order here;
149
+ all four when left out."""
150
+ return [FUNCTIONS[name] for name in _names(tool_names)]
151
+
152
+
153
+ def datacircle_async_functions(tool_names: Optional[Sequence[str]] = None) -> List[Callable[..., Awaitable[str]]]:
154
+ """The async functions, for a prompt on an async def: the same names and arguments as datacircle_functions()."""
155
+ return [ASYNC_FUNCTIONS[name] for name in _names(tool_names)]
156
+
157
+
158
+ def _given(name: str, arguments: Any) -> Dict[str, Any]:
159
+ _names([name])
160
+ if isinstance(arguments, (str, bytes)):
161
+ arguments = json.loads(arguments or "{}")
162
+ given = arguments if isinstance(arguments, Mapping) else {}
163
+ return {key: given.get(key) for key in _ARGUMENTS[name]}
164
+
165
+
166
+ def run(name: str, arguments: Any = None) -> str:
167
+ """What a function gives the model for these arguments, as JSON text: the API's answer, or {"error": its words}.
168
+ arguments is a mapping or its JSON text; the ones the function doesn't take are left out."""
169
+ try:
170
+ given = _given(name, arguments)
171
+ except ValueError as error:
172
+ if name not in FUNCTIONS:
173
+ raise
174
+ return json.dumps({"error": f"the arguments are no JSON object: {error}"})
175
+ return FUNCTIONS[name](**given)
176
+
177
+
178
+ async def arun(name: str, arguments: Any = None) -> str:
179
+ """run() in a thread, for async code."""
180
+ return await asyncio.to_thread(run, name, arguments)
181
+
182
+
183
+ __all__: List[str] = ["ASYNC_FUNCTIONS", "FUNCTIONS", "TOOL_NAMES", "arun", "datacircle_async_functions",
184
+ "datacircle_best_plans", "datacircle_functions", "datacircle_list_apis", "datacircle_provider",
185
+ "datacircle_search_plans", "run"]
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.5
2
+ Name: magentic-datacircle
3
+ Version: 0.1.0
4
+ Summary: magentic functions for the Datacircle API: find the best GTM APIs
5
+ Project-URL: Homepage, https://datacircle.dev
6
+ Project-URL: Documentation, https://api.datacircle.dev/v1/openapi.json
7
+ Project-URL: Repository, https://github.com/waynehamadi/magentic-datacircle
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: api,api-pricing,b2b-data,datacircle,function-calling,gtm,llm,magentic,prompt-chain,tools
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Libraries
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: pydantic>=2.10
16
+ Description-Content-Type: text/markdown
17
+
18
+ # magentic-datacircle
19
+
20
+ Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website.
21
+
22
+ Our website: https://datacircle.dev
23
+
24
+ This package gives [magentic](https://github.com/jackmpcollins/magentic) four functions that call Datacircle's open API, https://api.datacircle.dev/v1. You need no key and no account. Each function has type hints and a docstring. Each argument has a description. magentic reads the name, docstring and arguments of each function. magentic sends the name, docstring and arguments to the model.
25
+
26
+ | Function | What the function gives | Call |
27
+ | --- | --- | --- |
28
+ | `datacircle_list_apis` | Every GTM API on Datacircle, with the API's slug, number of plans, number of providers and best plan | `GET /apis` |
29
+ | `datacircle_best_plans` | One API's plans, sorted by score out of 100, best first. Each plan comes with a rank and a price per 1,000 calls | `GET /apis/{slug}/best` |
30
+ | `datacircle_search_plans` | Plans that match a provider or plan name, on all APIs or on one API. You can sort them by score, provider or price | `GET /plans` |
31
+ | `datacircle_provider` | The APIs a provider sells, and the provider's rank on each API | `GET /providers/{slug}` |
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ pip install magentic-datacircle magentic
37
+ ```
38
+
39
+ magentic-datacircle works with magentic 0.40 and later, on Python 3.10 and later. magentic-datacircle does not import `magentic`.
40
+
41
+ magentic uses OpenAI's `gpt-4o` by default. To use another model for each prompt, set `MAGENTIC_OPENAI_MODEL`. To use another model for one prompt, pass `model=` to that prompt. The Datacircle functions work with each of magentic's chat models: `OpenaiChatModel`, `AnthropicChatModel` and `LitellmChatModel`.
42
+
43
+ ## Use the functions in a prompt chain
44
+
45
+ With `@prompt_chain`, magentic runs each function call from the model. magentic then gives each function result back to the model. magentic repeats these steps until the model has the final answer:
46
+
47
+ ```python
48
+ from magentic import prompt_chain
49
+ from magentic_datacircle import datacircle_functions
50
+
51
+
52
+ @prompt_chain("Who are the 3 best providers for the {api} API? Name each with its score.", functions=datacircle_functions())
53
+ def best_providers(api: str) -> str: ...
54
+
55
+
56
+ print(best_providers("email-finder"))
57
+ ```
58
+
59
+ ## Call the function yourself
60
+
61
+ With `@prompt`, the model returns a `FunctionCall`. You choose when to call the `FunctionCall`:
62
+
63
+ ```python
64
+ from magentic import FunctionCall, prompt
65
+ from magentic_datacircle import datacircle_functions
66
+
67
+
68
+ @prompt("Find the best plans for the {api} API.", functions=datacircle_functions())
69
+ def plan(api: str) -> FunctionCall[str]: ...
70
+
71
+
72
+ call = plan("email-finder")
73
+ print(call())
74
+ ```
75
+
76
+ To get many calls at once, set the return type to `ParallelFunctionCall[str]`.
77
+
78
+ ## Use the Datacircle functions in a chat prompt
79
+
80
+ `@chatprompt` takes `functions=datacircle_functions()`:
81
+
82
+ ```python
83
+ from magentic import FunctionCall, SystemMessage, UserMessage, chatprompt
84
+ from magentic_datacircle import datacircle_functions
85
+
86
+
87
+ @chatprompt(
88
+ SystemMessage("Use the Datacircle functions for questions on GTM APIs."),
89
+ UserMessage("On which APIs does {provider} rank?"),
90
+ functions=datacircle_functions(),
91
+ )
92
+ def ranks(provider: str) -> FunctionCall[str]: ...
93
+
94
+
95
+ print(ranks("Hunter")())
96
+ ```
97
+
98
+ ## Use the functions in async code
99
+
100
+ For a prompt on an `async def`, use `datacircle_async_functions()`. The async functions have the same names and arguments as the sync functions. Each async function runs the API call in a thread. Several calls then run at the same time:
101
+
102
+ ```python
103
+ import asyncio
104
+
105
+ from magentic import prompt_chain
106
+ from magentic_datacircle import datacircle_async_functions
107
+
108
+
109
+ @prompt_chain("Who is the best provider for the {api} API?", functions=datacircle_async_functions())
110
+ async def best_provider(api: str) -> str: ...
111
+
112
+
113
+ print(asyncio.run(best_provider("email-finder")))
114
+ ```
115
+
116
+ ## Use the Datacircle functions beside your own functions
117
+
118
+ Put the Datacircle functions in one list with your own functions: `functions=[*datacircle_functions(), my_function]`.
119
+
120
+ To give the model only some Datacircle functions, list the names of those functions: `datacircle_functions(["datacircle_best_plans"])`.
121
+
122
+ ## Call a function without a model
123
+
124
+ Each function runs without a model. You get the Datacircle API's answer as JSON text:
125
+
126
+ ```python
127
+ import json
128
+
129
+ from magentic_datacircle import datacircle_best_plans, run
130
+
131
+ print(json.loads(datacircle_best_plans("email-finder", limit=3))["plans"])
132
+ print(run("datacircle_provider", {"slug": "Bright Data"}))
133
+ ```
134
+
135
+ ## What the model reads
136
+
137
+ Each function returns the API's answer as JSON text. magentic gives the model this text with every backend. Each plan comes with a rank, provider, plan, score, price per 1,000 (`perThousand`, in dollars) and a page on datacircle.dev. That page lists every field.
138
+
139
+ You can give a provider's name in place of a slug. The function turns `Bright Data` into `bright-data`.
140
+
141
+ An unknown slug gets no data from the API. With no data, the function returns `{"error": "..."}` and the API's message. The error for an unknown API slug lists every valid slug. The function checks each number from the model before any API call. For a number out of range, the function returns `{"error": "..."}` and makes no API call. If the network fails, the function returns `{"error": "..."}` with the network error's message. The function never raises an error. Your prompt chain keeps running. The model can call the function again.
142
+
143
+ ## Network
144
+
145
+ Each function call makes one HTTPS GET request to https://api.datacircle.dev/v1 and nothing else. The request holds only the function's own arguments: no key and nothing from your prompts. The API takes up to 60 calls a minute from one IP address. The API can ask the function to wait. The function then waits once, for a minute at most. Each call uses only Python's standard library. Nothing goes to disk.
146
+
147
+ ## Links
148
+
149
+ - Datacircle: https://datacircle.dev
150
+ - The API's spec: https://api.datacircle.dev/v1/openapi.json
@@ -0,0 +1,8 @@
1
+ magentic_datacircle/__init__.py,sha256=9Y7CXQeK9lECVu_miG8f4uaF1wUKVSw2NHUaXEcq9G4,762
2
+ magentic_datacircle/_api.py,sha256=sc0aXCGcybrzXamR2qifjrSlBUS9fR9H5q2mj5PPjKg,4869
3
+ magentic_datacircle/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ magentic_datacircle/tools.py,sha256=SG5dLCvPfFrt6pWCSQFUc32WNBaW_DdezGiRcaSQF8s,11085
5
+ magentic_datacircle-0.1.0.dist-info/METADATA,sha256=UzhgBueXak8ce4myPcoX42XDGFUo8_sJePqv7EYQDkA,6715
6
+ magentic_datacircle-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
7
+ magentic_datacircle-0.1.0.dist-info/licenses/LICENSE,sha256=dpgF7zGxeOd9IpQ9yUGa4a-cTj8fI6ulHnuilZEonCo,1067
8
+ magentic_datacircle-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Datacircle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.