@xyz17711/url-extract 0.1.1 → 0.1.2
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.
- package/README.md +7 -4
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,10 +26,13 @@ npm install @xyz17711/url-extract
|
|
|
26
26
|
```typescript
|
|
27
27
|
import { Client } from "@xyz17711/url-extract";
|
|
28
28
|
|
|
29
|
-
const client = new Client(
|
|
29
|
+
const client = new Client(); // talks to https://api.17711.xyz/registry/url-extract-service by default
|
|
30
30
|
// see the Methods table above for every available call and its request/response type
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
Pass another base URL (self-hosted instance, test server) as the first argument:
|
|
34
|
+
`new Client("https://my-host.example/registry/url-extract-service")`.
|
|
35
|
+
|
|
33
36
|
## Paying past the free quota
|
|
34
37
|
|
|
35
38
|
Every gated tool allows a small number of free calls per day; beyond that it returns a 402
|
|
@@ -39,7 +42,7 @@ network, and payee address attached:
|
|
|
39
42
|
```typescript
|
|
40
43
|
import { Client, PaymentRequiredError } from "@xyz17711/url-extract";
|
|
41
44
|
|
|
42
|
-
const client = new Client(
|
|
45
|
+
const client = new Client();
|
|
43
46
|
try {
|
|
44
47
|
await client.getCompanyProfile(/* ... */);
|
|
45
48
|
} catch (e) {
|
|
@@ -55,7 +58,7 @@ own environment/secrets manager, never a literal string in source code:
|
|
|
55
58
|
```typescript
|
|
56
59
|
import { Client } from "@xyz17711/url-extract";
|
|
57
60
|
|
|
58
|
-
const client = new Client(
|
|
61
|
+
const client = new Client({
|
|
59
62
|
x402PrivateKey: process.env.X402_PRIVATE_KEY,
|
|
60
63
|
x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
|
|
61
64
|
x402MaxPaymentUsdc: 0.01, // refuse any single call above this
|
|
@@ -74,7 +77,7 @@ with that same key in this process.
|
|
|
74
77
|
import { Client } from "@xyz17711/url-extract";
|
|
75
78
|
import { UrlExtractToolkit } from "@xyz17711/url-extract/langchain";
|
|
76
79
|
|
|
77
|
-
const client = new Client(
|
|
80
|
+
const client = new Client({ /* ...wallet options... */ });
|
|
78
81
|
const tools = new UrlExtractToolkit(client).getTools();
|
|
79
82
|
```
|
|
80
83
|
|
package/dist/index.d.ts
CHANGED
|
@@ -94,8 +94,17 @@ export interface GetStructuredDataRequest {
|
|
|
94
94
|
/** Address of the web page to read (`http` or `https`). */
|
|
95
95
|
url: string;
|
|
96
96
|
}
|
|
97
|
+
/** Production base URL of this service; pass another to self-host or test. */
|
|
98
|
+
export declare const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/url-extract-service";
|
|
97
99
|
/** Typed client for url-extract-service, e.g. `client.getCompanyProfile(...)`. */
|
|
98
100
|
export declare class Client extends BaseClient {
|
|
101
|
+
/**
|
|
102
|
+
* `new Client()` talks to the production service. Pass a base URL to target another
|
|
103
|
+
* instance, and/or wallet options (`new Client({ x402PrivateKey, ... })`) to pay past the
|
|
104
|
+
* free quota automatically.
|
|
105
|
+
*/
|
|
106
|
+
constructor(options?: ClientOptions);
|
|
107
|
+
constructor(baseUrl?: string, options?: ClientOptions);
|
|
99
108
|
/** [Deprecated - use company_profile_get_profile] Company profile from a domain or a name as valid JSON ($0.009, x402) */
|
|
100
109
|
getCompanyProfile(request: GetCompanyProfileRequest): Promise<GetCompanyProfileResponse>;
|
|
101
110
|
/** URL extract with a question: ask any web page a question and get structured data as JSON that matches your schema ($0.02, x402) */
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,16 @@
|
|
|
2
2
|
* Typed HTTP client and request/response interfaces for url-extract-service.
|
|
3
3
|
*/
|
|
4
4
|
import { Client as BaseClient } from "@xyz17711/core";
|
|
5
|
+
/** Production base URL of this service; pass another to self-host or test. */
|
|
6
|
+
export const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/url-extract-service";
|
|
5
7
|
/** Typed client for url-extract-service, e.g. `client.getCompanyProfile(...)`. */
|
|
6
8
|
export class Client extends BaseClient {
|
|
9
|
+
constructor(baseUrlOrOptions, options = {}) {
|
|
10
|
+
const [url, opts] = typeof baseUrlOrOptions === "object"
|
|
11
|
+
? [DEFAULT_BASE_URL, baseUrlOrOptions]
|
|
12
|
+
: [baseUrlOrOptions ?? DEFAULT_BASE_URL, options];
|
|
13
|
+
super(url, opts);
|
|
14
|
+
}
|
|
7
15
|
/** [Deprecated - use company_profile_get_profile] Company profile from a domain or a name as valid JSON ($0.009, x402) */
|
|
8
16
|
async getCompanyProfile(request) {
|
|
9
17
|
return this.post("/v1/url-extract/get_company_profile", request);
|
package/package.json
CHANGED