@@ -75,14 +75,19 @@ place to configure the SDK.
7575| ----------| ---------| ---------|
7676| ` token ` | — (required) | all |
7777| ` timeout ` | ` 30.0 ` (seconds) | all |
78+ | ` retry ` | on, 3 attempts | all; ` False ` disables, or pass a ` RetryPolicy ` to tune it |
7879| ` transport ` | httpx default | all |
79- | ` analyze_url ` | ` https://api.diffbot.com/v3 ` | ` extract ` |
80- | ` crawler_url ` | ` https://api.diffbot.com/v3/crawl ` | ` crawl ` , ` crawl_list_jobs ` , ` crawl_get_job ` , ` crawl_delete_job ` |
81- | ` llm_url ` | ` https://llm.diffbot.com/rag/v1/chat/completions ` | ` ask ` , ` ask_json ` |
82- | ` web_search_url ` | ` https://llm.diffbot.com/api/v1/web_search ` | ` web_search ` |
83- | ` nlp_url ` | ` https://nl.diffbot.com/v1/ ` | ` entities ` |
84- | ` dql_url ` | ` https://kg.diffbot.com/kg/v3/dql ` | ` dql ` , ` dql_parallel ` |
85- | ` ontology_url ` | ` https://kg.diffbot.com/kg/ontology ` | ` dql_fetch_ontology ` , ` dql_refresh_ontology ` |
80+ | ` api_base ` | ` https://api.diffbot.com ` | ` extract ` , ` crawl ` , ` crawl_list_jobs ` , ` crawl_get_job ` , ` crawl_delete_job ` |
81+ | ` kg_base ` | ` https://kg.diffbot.com ` | ` dql ` , ` dql_parallel ` , ` dql_fetch_ontology ` , ` dql_refresh_ontology ` |
82+ | ` llm_base ` | ` https://llm.diffbot.com ` | ` ask ` , ` ask_json ` , ` web_search ` |
83+ | ` nlp_base ` | ` https://nl.diffbot.com ` | ` entities ` |
84+ | ` analyze_url ` | derived from ` api_base ` | ` extract ` |
85+ | ` crawler_url ` | derived from ` api_base ` | ` crawl ` , ` crawl_list_jobs ` , ` crawl_get_job ` , ` crawl_delete_job ` |
86+ | ` llm_url ` | derived from ` llm_base ` | ` ask ` , ` ask_json ` |
87+ | ` web_search_url ` | derived from ` llm_base ` | ` web_search ` |
88+ | ` nlp_url ` | derived from ` nlp_base ` | ` entities ` |
89+ | ` dql_url ` | derived from ` kg_base ` | ` dql ` , ` dql_parallel ` |
90+ | ` ontology_url ` | derived from ` kg_base ` | ` dql_fetch_ontology ` , ` dql_refresh_ontology ` |
8691
8792``` python
8893from diffbot import Diffbot
@@ -94,12 +99,35 @@ db = Diffbot(
9499)
95100```
96101
97- ` analyze_url ` is a base the SDK appends ` /{api} ` to, and ` crawler_url ` is used as given
98- for job management and with ` /data ` appended for crawl results. The rest are complete
99- endpoints, used as given.
102+ Point the whole SDK at a staging environment with one option instead of one per endpoint:
100103
101- Passing ` transport ` replaces the httpx transport, which is the hook for retries, proxies,
102- or mocking in tests. ` Diffbot ` takes an ` httpx.BaseTransport ` , ` DiffbotAsync ` an
104+ ``` python
105+ staging = Diffbot(token = " YOUR_TOKEN" , api_base = " https://staging.example.com" )
106+ ```
107+
108+ ` api_base ` /` kg_base ` /` llm_base ` /` nlp_base ` set the host for every endpoint on that host
109+ at once. The older per-endpoint options (` analyze_url ` , ` crawler_url ` , ` llm_url ` ,
110+ ` web_search_url ` , ` nlp_url ` , ` dql_url ` , ` ontology_url ` ) still work and win over the
111+ matching base when both are set; ` analyze_url ` is a base the SDK appends ` /{api} ` to,
112+ ` crawler_url ` is used as given for job management and with ` /data ` appended for crawl
113+ results, and the rest are complete endpoints used as given.
114+
115+ Requests retry ` 429 ` and ` 5xx ` responses (and connection errors) with backoff and
116+ jitter, honoring a ` Retry-After ` header, by default. Disable retries or tune the policy:
117+
118+ ``` python
119+ from diffbot import Diffbot, RetryPolicy
120+
121+ db = Diffbot(token = " YOUR_TOKEN" , retry = False )
122+ # or: retry=RetryPolicy(max_attempts=5)
123+ ```
124+
125+ The transport also accepts a per-call ` retryable=False ` escape hatch; the SDK uses it
126+ internally for ` crawl_delete_job ` , a GET-shaped mutation that must not be retried
127+ blindly.
128+
129+ Passing ` transport ` replaces the httpx transport, which is the hook for proxies or
130+ mocking in tests. ` Diffbot ` takes an ` httpx.BaseTransport ` , ` DiffbotAsync ` an
103131` httpx.AsyncBaseTransport ` :
104132
105133``` python
0 commit comments