• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

astronomer / astro-cli / bd0008aa-1a67-44ce-bf76-235040fa846e

05 Feb 2026 08:38PM UTC coverage: 33.306% (+0.2%) from 33.15%
bd0008aa-1a67-44ce-bf76-235040fa846e

push

circleci

jeremybeard
Add `astro api` command for authenticated Airflow and Cloud API requests

Introduce the `astro api` top-level command with two subcommands:

  astro api airflow — make requests to the Airflow REST API (local or
  deployed), with automatic version detection (2.x, 3.0.x, 3.0.3+) and
  OpenAPI spec resolution.

  astro api cloud — make requests to the Astro Cloud platform API using
  the current context's bearer token.

Both subcommands support:
  - Endpoint discovery via `ls` and `describe` (parsed from OpenAPI specs)
  - Calling endpoints by operation ID or raw path
  - Pagination (per-page streaming or --slurp into a single array)
  - Response caching with TTL and automatic stale-entry cleanup
  - jq filters and Go-template output formatting
  - Colored JSON output
  - --curl flag to emit equivalent curl commands
  - Magic field syntax for request bodies (@file, :=json, =string)
  - Custom headers and path-parameter overrides

Supporting packages:
  - pkg/openapi: OpenAPI spec fetching, caching, endpoint indexing,
    Airflow version-range mapping, and schema introspection.

Includes unit tests for request handling, output formatting, field
parsing, OpenAPI version mapping, endpoint indexing, and caching.

903 of 2396 new or added lines in 13 files covered. (37.69%)

9 existing lines in 1 file now uncovered.

21761 of 65337 relevant lines covered (33.31%)

8.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/api/api.go
1
// Package api provides the 'astro api' command for making authenticated API requests.
2
package api
3

4
import (
5
        "io"
6
        "os"
7

8
        "github.com/fatih/color"
9
        "github.com/spf13/cobra"
10
)
11

12
// NewAPICmd creates the parent 'astro api' command.
NEW
13
func NewAPICmd() *cobra.Command {
×
NEW
14
        return NewAPICmdWithOutput(os.Stdout)
×
NEW
15
}
×
16

17
// NewAPICmdWithOutput creates the parent 'astro api' command with a custom output writer.
NEW
18
func NewAPICmdWithOutput(out io.Writer) *cobra.Command {
×
NEW
19
        var noColor bool
×
NEW
20

×
NEW
21
        cmd := &cobra.Command{
×
NEW
22
                Use:           "api",
×
NEW
23
                Short:         "Make authenticated API requests to Astronomer services",
×
NEW
24
                SilenceErrors: true, // API commands print error bodies themselves; don't let cobra double-print
×
NEW
25
                SilenceUsage:  true,
×
NEW
26
                Long: `Make authenticated HTTP requests to Astronomer APIs and print responses.
×
NEW
27

×
NEW
28
The 'astro api' command provides direct access to Astronomer's REST APIs,
×
NEW
29
similar to 'gh api' for GitHub or 'vercel api' for Vercel.
×
NEW
30

×
NEW
31
Available subcommands:
×
NEW
32
  airflow  Make requests to the Airflow REST API
×
NEW
33
  cloud    Make requests to the Astro Cloud API (api.astronomer.io)
×
NEW
34

×
NEW
35
Use "astro api [command] --help" for more information about a command.`,
×
NEW
36
                PersistentPreRun: func(cmd *cobra.Command, args []string) {
×
NEW
37
                        if noColor {
×
NEW
38
                                color.NoColor = true
×
NEW
39
                        }
×
40
                },
NEW
41
                Run: func(cmd *cobra.Command, args []string) {
×
NEW
42
                        _ = cmd.Help()
×
NEW
43
                },
×
44
        }
45

NEW
46
        cmd.PersistentFlags().BoolVar(&noColor, "no-color", false, "Disable colorized output")
×
NEW
47

×
NEW
48
        cmd.AddCommand(NewAirflowCmd(out))
×
NEW
49
        cmd.AddCommand(NewCloudCmd(out))
×
NEW
50

×
NEW
51
        return cmd
×
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc