Skip to content

Commit 945f136

Browse files
feat: add godaddy api command for direct API access
Add a new command that allows direct, authenticated requests to any GoDaddy API endpoint, similar to `gh api` and `vercel api`. Features: - Support for all HTTP methods (GET, POST, PUT, PATCH, DELETE) - Field arguments (-f key=value) and JSON file body (-F path) - Custom headers (-H "Key: Value") - JSON path queries for filtering output (-q .path.to.value) - Response header display (-i, --include) - Debug mode shows request/response details (--debug) - Proactive token expiry checking with helpful messages - Specific handling for 401/403 responses Also includes: - Comprehensive documentation in README - Unit tests for API module and command - Improved test reliability for CI environments Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bfe4e35 commit 945f136

13 files changed

Lines changed: 1205 additions & 46 deletions

File tree

CLAUDE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# CLAUDE.md
1+
# CLAUDE.md - GoDaddy CLI
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5+
## Local Development Ports
6+
7+
This is a command-line application that does not run on a network port.
8+
59
# GoDaddy CLI Development Guide
610

711
## Commands

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pnpm tsx src/index.tsx application <command>
2424

2525
## Features
2626

27+
- **API Access**: Make direct, authenticated requests to any GoDaddy API endpoint
2728
- **Application Management**: Create, view, and release applications
2829
- **Authentication**: Secure OAuth-based authentication with GoDaddy
2930
- **Webhook Management**: List available webhook event types
@@ -230,6 +231,102 @@ godaddy webhook events # Lists all available webhook event types y
230231
-o, --output <format> # Output format: json or text (default: text)
231232
```
232233

234+
### API Command
235+
236+
The `api` command allows you to make direct, authenticated requests to any GoDaddy API endpoint. This is useful for exploring APIs, debugging, automation scripts, and AI agent integrations.
237+
238+
```bash
239+
# Basic GET request
240+
godaddy api <endpoint>
241+
242+
# Specify HTTP method
243+
godaddy api <endpoint> -X <method> # method: GET, POST, PUT, PATCH, DELETE
244+
245+
# Full options
246+
godaddy api <endpoint>
247+
Options:
248+
-X, --method <method> # HTTP method (default: GET)
249+
-f, --field <key=value> # Add field to request body (can be repeated)
250+
-F, --file <path> # Read request body from JSON file
251+
-H, --header <header> # Add custom header (can be repeated)
252+
-q, --query <path> # Extract value at JSON path
253+
-i, --include # Include response headers in output
254+
```
255+
256+
#### Examples
257+
258+
```bash
259+
# Get current shopper info
260+
godaddy api /v1/shoppers/me
261+
262+
# Get domains list
263+
godaddy api /v1/domains
264+
265+
# Check domain availability (POST with field)
266+
godaddy api /v1/domains/available -X POST -f domain=example.com
267+
268+
# Extract a specific field from the response
269+
godaddy api /v1/shoppers/me -q .shopperId
270+
271+
# Extract nested data
272+
godaddy api /v1/domains -q .domains[0].domain
273+
274+
# Include response headers
275+
godaddy api /v1/shoppers/me -i
276+
277+
# Add custom headers
278+
godaddy api /v1/domains -H "X-Request-Context: cli-test"
279+
280+
# POST with JSON file body
281+
godaddy api /v1/domains/purchase -X POST -F ./domain-request.json
282+
283+
# Multiple fields
284+
godaddy api /v1/domains/contacts -X PUT \
285+
-f firstName=John \
286+
-f lastName=Doe \
287+
-f email=john@example.com
288+
289+
# Debug mode (shows request/response details)
290+
godaddy --debug api /v1/shoppers/me
291+
```
292+
293+
#### Query Path Syntax
294+
295+
The `-q, --query` option supports simple JSON path expressions:
296+
297+
| Pattern | Description | Example |
298+
|---------|-------------|---------|
299+
| `.key` | Access object property | `.shopperId` |
300+
| `.key.nested` | Access nested property | `.customer.email` |
301+
| `[0]` | Access array index | `[0]` |
302+
| `.key[0]` | Combined access | `.domains[0]` |
303+
| `.key[0].nested` | Complex path | `.domains[0].status` |
304+
305+
#### Authentication
306+
307+
The `api` command uses the same authentication as other CLI commands. You must be logged in:
308+
309+
```bash
310+
# Login first
311+
godaddy auth login
312+
313+
# Then make API calls
314+
godaddy api /v1/shoppers/me
315+
```
316+
317+
#### Common API Endpoints
318+
319+
| Endpoint | Description |
320+
|----------|-------------|
321+
| `/v1/shoppers/me` | Current authenticated shopper |
322+
| `/v1/domains` | List domains |
323+
| `/v1/domains/available` | Check domain availability |
324+
| `/v1/domains/{domain}` | Get specific domain info |
325+
| `/v1/orders` | List orders |
326+
| `/v1/subscriptions` | List subscriptions |
327+
328+
For the complete API reference, visit the [GoDaddy Developer Portal](https://developer.godaddy.com/).
329+
233330
### Actions Commands
234331

235332
```bash

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@godaddy/cli",
33
"version": "0.1.0",
44
"description": "GoDaddy CLI for managing applications and webhooks",
5+
"keywords": ["godaddy", "cli", "developer-tools"],
56
"main": "./dist/cli.js",
67
"type": "module",
78
"bin": {

0 commit comments

Comments
 (0)