Flags API

How to use the flag API to call for and retrieve flag details.

Published on: 13 May 2025

Table of Contents

Overview

The RocketFlag API aims to be as simple as possible to use in the most basic form of a feature flag. It aims to answer this one question:

“Is this flag enabled for me?”

Calling

To use the API, simply make a GET request to the following URL replacing flagID with your flag’s ID. For example:

 https://api.rocketflag.app/v1/flags/flagId

Samples

Suppose your Flag ID was ABCdef12345. Check out some of the samples below.

cURL

curl -XGET 'https://api.rocketflag.app/v1/flags/ABCdef12345'

Javascript

const response = await fetch("https://api.rocketflag.app/v1/flags/ABCdef12345", {
  method: "GET",
});

Node SDK

const rocketflag = createRocketflagClient();
const flag = await rocketflag.getFlag("ABCdef12345");

Python

import requests
response = requests.get("https://api.rocketflag.app/v1/flags/ABCdef12345")

Ruby

require 'net/http'
response = Net::HTTP.get("https://api.rocketflag.app/v1/flags/ABCdef12345")

Go (golang)

package main

import (
	"fmt"
	"net/http"
)

func main() {
	resp, err := http.Get("https://api.rocketflag.app/v1/flags/ABCdef12345")
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(resp)
	}
}

SDK

If you are developing with Node/Javascript or Go, you can take advantage of the SDK which will make this a lot easier to use. It’s just a thin wrapper around the http call described above.

Instructions for using and installing the SDK can be found on the respective GitHub pages:

If you have a need for a language which isn’t listed, please contact me and I’d love to hear about it.

Response

The response from the API will be in JSON format, with two keys and their values. The name of the flag and the response from that query. For example:

{ "name": "My flag", "enabled": true, "flagId": "ABCdef12345" }

Good to know:

The flag ID can be found on the project’s page which shows all the flags and in the downloadable YAML file available from on top of the flags table.

Cohorts

If you’d like to use a cohort in your request, just pass it in as a query string as so:

curl -XGET 'https://api.rocketflag.app/v1/flags/ABCdef12345?cohort=user@example.com'

Node Example

const response = await fetch("https://api.rocketflag.app/v1/flags/ABCdef12345?cohort=user@example.com", {
  method: "GET",
});

From the Go SDK:

flag, err := rf.GetFlag("ABCdef12345"", rocketflag.UserContext{
  "cohort": "user@example.com",
})

From the Node SDK:

const flag = await rocketflag.getFlag("ABCdef12345", {
  cohort: "user@example.com",
});

Read next: RocketFlag Node SDK