Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@
- [LLM: OpenAI Chat Completion](tools/llm-openai-chat-completion/README.md)
- [Social : X](tools/social-twitter/README.md)
- [Storage: Walrus](tools/storage-walrus/README.md)

## Looking for a home

* [tools/http/README.md](tools/http/README.md)
* [tools/market-coinbase/README.md](tools/market-coinbase/README.md)
1 change: 1 addition & 0 deletions nexus-sdk/guides/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ Open the [Talus Sui Explorer](https://explorer.devnet.taluslabs.dev/).
---

After completing these steps, you are ready to build and execute workflows using the Nexus SDK. To build your first workflow, check the [Dev Quickstart guide](math-branching-quickstart.md).

155 changes: 155 additions & 0 deletions tools/http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# `xyz.taluslabs.http.request@1`

Standard Nexus Tool that makes HTTP requests with support for various authentication methods, body types, and response validation.

## Input

**`method`: [`HttpMethod`]**

The HTTP method to use for the request.

- **`GET`** - Retrieve data from the server
- **`POST`** - Send data to the server
- **`PUT`** - Update existing data on the server
- **`DELETE`** - Remove data from the server
- **`PATCH`** - Partially update data on the server
- **`HEAD`** - Retrieve only headers from the server
- **`OPTIONS`** - Get allowed methods for a resource

**`url`: [`UrlInput`]**

The URL for the request. Can be provided in two formats:

- **Full URL**: `"https://api.example.com/users"`
- **Split URL**: `{ "base_url": "https://api.example.com", "path": "/users" }`

_opt_ **`headers`: [`Option<HashMap<String, String>>`]** _default_: [`None`]

Custom HTTP headers to include in the request.

_opt_ **`query`: [`Option<HashMap<String, String>>`]** _default_: [`None`]

Query parameters to append to the URL.

_opt_ **`auth`: [`Option<AuthConfig>`]** _default_: [`None`]

Authentication configuration for the request.

### AuthConfig Options

- **`None`** - No authentication
- **`BearerToken { token }`** - Bearer token authentication
- **`ApiKeyHeader { key, header_name }`** - API key in header (default: "X-API-Key")
- **`ApiKeyQuery { key, param_name }`** - API key in query parameter (default: "api_key")
- **`BasicAuth { username, password }`** - Basic authentication

_opt_ **`body`: [`Option<RequestBody>`]** _default_: [`None`]

Request body configuration.

### RequestBody Options

- **`Json { data }`** - JSON request body
- **`Form { data }`** - URL-encoded form data
- **`Multipart { fields }`** - Multipart form data for text fields
- **`Raw { data, content_type }`** - Raw bytes (base64 encoded)

### MultipartField Structure

- **`name`: [`String`]** - Field name
- **`value`: [`String`]** - Field value (text only)
- **`content_type`: [`Option<String>`]** - Content type for the field

_opt_ **`expect_json`: [`Option<bool>`]** _default_: [`None`]

Whether to expect a JSON response. If true, attempts to parse the response as JSON.

_opt_ **`json_schema`: [`Option<HttpJsonSchema>`]** _default_: [`None`]

Optional JSON schema to validate the response against.

### HttpJsonSchema Structure

- **`name`: [`String`]** - The name of the schema
- **`schema`: [`schemars::Schema`]** - The JSON schema for validation
- **`description`: [`Option<String>`]** - Description of the expected format
- **`strict`: [`Option<bool>`]** - Whether to enable strict schema adherence

_opt_ **`timeout_ms`: [`Option<u64>`]** _default_: [`5000`]

Request timeout in milliseconds. Maximum allowed value is 30000ms (30 seconds). The timeout applies to the **entire request chain**, including all redirects when `follow_redirects` is enabled. For example, if `timeout_ms: 5000` is set and a request follows 3 redirects

_opt_ **`retries`: [`Option<u32>`]** _default_: [`0`]

Number of retries on failure. Maximum allowed value is 5.

_opt_ **`follow_redirects`: [`Option<bool>`]** _default_: [`false`]

Whether to follow HTTP redirects. Defaults to false, following curl's philosophy of not following redirects unless explicitly requested. When enabled, follows up to 3 redirects maximum

## Security Features

**Localhost Blocking**: Requests to `localhost` and `127.0.0.1` are blocked for security reasons. This prevents internal network scanning and ensures the tool only makes external requests.

## Output Variants & Ports

**`ok`**

The HTTP request was successful.

```json
{
"type": "ok",
"status": 200,
"headers": {...},
"raw_base64": "...",
"text": "...",
"json": {...},
"schema_validation": {...}
}
```

- **`type`: [`"ok"`]** - Response type identifier
- **`status`: [`u16`]** - HTTP status code
- **`headers`: [`HashMap<String, String>`]** - Response headers
- **`raw_base64`: [`String`]** - Raw response body (base64 encoded)
- **`text`: [`Option<String>`]** - Text representation (if UTF-8 decodable)
- **`json`: [`Option<Value>`]** - JSON data (if parseable)
- **`schema_validation`: [`Option<SchemaValidationDetails>`]** - Schema validation details (if validation was performed)

### SchemaValidationDetails Structure

- **`name`: [`String`]** - Name of the schema that was used
- **`description`: [`Option<String>`]** - Description of the schema
- **`strict`: [`Option<bool>`]** - Whether strict mode was enabled
- **`valid`: [`bool`]** - Validation result
- **`errors`: [`Vec<String>`]** - Validation errors (if any)

**`err`**

An error occurred during the request.

```json
{
"type": "err",
"reason": "HTTP error 404: Not Found",
"kind": "err_http",
"status_code": 404
}
```

- **`type`: [`"err"`]** - Response type identifier
- **`reason`: [`String`]** - Detailed error message
- **`kind`: [`HttpErrorKind`]** - Type of error
- **`status_code`: [`Option<u16>`]** - HTTP status code if available

### HttpErrorKind Values

- **`err_http`** - HTTP error response (4xx, 5xx)
- **`err_json_parse`** - JSON parsing error
- **`err_schema_validation`** - Schema validation error
- **`err_network`** - Network connectivity error
- **`err_timeout`** - Request timeout error
- **`err_input`** - Input validation error
- **`err_url_parse`** - URL parsing error
- **`err_base64_decode`** - Base64 decoding error
37 changes: 37 additions & 0 deletions tools/market-coinbase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# `xyz.taluslabs.market.coinbase.get-spot-price@1`

Standard Nexus Tool that retrieves the current spot price for a currency pair from Coinbase. Coinbase API [reference](https://docs.cdp.coinbase.com/coinbase-app/track-apis/prices)

## Input

**`currency_pair`: [`String` | `Vec<String>`]**

The currency pair to get spot price for. Can be provided in multiple formats:

- **Full pair string**: `"BTC-USD"`, `"ETH-EUR"`, `"SUI-USD"`
- **Array format**: `["BTC", "USD"]`, `["ETH", "EUR"]`, `["SUI", "USD"]`
- **Base currency only**: `"BTC"`, `"ETH"`, `"SUI"` (when `quote_currency` is provided)

**`quote_currency`: [`String`] (optional)**

The quote currency to pair with the base currency. When provided, `currency_pair` should contain only the base currency (e.g., `"BTC"` with `quote_currency: "USD"`).

**`date`: [`String`] (optional)**

The date for historical spot price in YYYY-MM-DD format (e.g., `"2025-08-21"`). If not provided, returns the current spot price.

## Output Variants & Ports

**`ok`**

The spot price was retrieved successfully.

- **`ok.amount`: [`String`]** - The price amount as a string
- **`ok.base`: [`String`]** - The base currency (e.g., "BTC", "ETH")
- **`ok.currency`: [`String`]** - The quote currency (e.g., "USD", "USDT")

**`err`**

The spot price request failed due to an error.

- **`err.reason`: [`String`]** - A detailed error message describing what went wrong