Fibonacci GeneratorFibonacci Generator API

OnlineCredit Usage:1 per callRefreshed 1 month ago
avg: 345ms|p50: 326ms|p75: 357ms|p90: 395ms|p99: 469ms

Overview

The Fibonacci Generator API computes Fibonacci sequence values along with derived statistics — a sum, the trailing 5 consecutive-value ratios, and the most recent ratio as an approximation of the golden ratio. It accepts two mutually-exclusive modes: `count` for a fixed-length response, or `maxvalue` for every Fibonacci number up to a numeric ceiling. An optional `startfrom` parameter advances the generator before emission begins. All arithmetic uses standard JavaScript Number type on the server, so values above Number.MAX_SAFE_INTEGER (around the 79th Fibonacci number) cannot be represented exactly — the precision ceiling is end-to-end. The ratios array is always truncated to the last 5 entries regardless of sequence length, and each ratio is rounded to 6 decimal places.

To use Fibonacci Generator, you need an API key. You can get one by creating a free account and visiting your dashboard.

GET Endpoint

URL
https://api.apiverve.com/v1/fibonaccigenerator

Example

The sequence array is prepended with 0 because startfrom defaulted to 0. The full set of consecutive-value ratios for this sequence would be eight entries — the ratio at position 0 (1/0) is skipped because of the zero-denominator rule, leaving ratios for indices 1 through 8 — but only the last 5 are returned, which is why the response contains [1.666667, 1.6, 1.625, 1.615385, 1.619048] rather than the full set. The golden_ratio_approximation field equals the final ratio entry (1.619048) and is already approaching φ even at this small count.

cURL Request
curl -X GET \
  "https://api.apiverve.com/v1/fibonaccigenerator?count=10&startfrom=0" \
  -H "X-API-Key: your_api_key_here"
JavaScript (Fetch API)
const response = await fetch('https://api.apiverve.com/v1/fibonaccigenerator?count=10&startfrom=0', {
  method: 'GET',
  headers: {
    'X-API-Key': 'your_api_key_here',
    'Content-Type': 'application/json'
  }
});

const data = await response.json();
console.log(data);
Python (Requests)
import requests

headers = {
    'X-API-Key': 'your_api_key_here',
    'Content-Type': 'application/json'
}

response = requests.get('https://api.apiverve.com/v1/fibonaccigenerator?count=10&startfrom=0', headers=headers)

data = response.json()
print(data)
Go (net/http)
package main

import (
    "fmt"
    "io"
    "net/http"

)

func main() {
    req, _ := http.NewRequest("GET", "https://api.apiverve.com/v1/fibonaccigenerator?count=10&startfrom=0", nil)

    req.Header.Set("X-API-Key", "your_api_key_here")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
Example Response
{
  "status": "ok",
  "error": null,
  "data": {
    "sequence": [
      0,
      1,
      1,
      2,
      3,
      5,
      8,
      13,
      21,
      34
    ],
    "count": 10,
    "start_from": 0,
    "first_value": 0,
    "last_value": 34,
    "sum": 88,
    "ratios": [
      1.666667,
      1.6,
      1.625,
      1.615385,
      1.619048
    ],
    "golden_ratio_approximation": 1.619048
  }
}

Authentication

The Fibonacci Generator API requires authentication via API key. Include your API key in the request header:

Required Header
X-API-Key: your_api_key_here

Learn more about authentication →

Interactive API Playground

Test the Fibonacci Generator API directly in your browser with live requests and responses.

Parameters

The Fibonacci Generator API supports multiple query options. Use one of the following:

Option 1: Generate by Count

ParameterTypeRequiredDescriptionDefaultExample
countintegerrequired
Number of Fibonacci numbers to generate
Range: 1 - 1000
Behavior: Decimals are rejected with HTTP 400 ('must be a valid integer (no decimals)') rather than truncated. Out-of-range values are rejected, not clamped.
-10
startfromintegeroptional
Start from this position in the sequence
Range: min: 0
Behavior: Advances the generator's internal state N steps before emission, so startfrom=N produces a sequence starting at F(N+1) for N≥1, or F(0)=0 for N=0. The leading 0 only appears when startfrom is exactly 0.
--

Option 2: Generate up to Maximum Value

ParameterTypeRequiredDescriptionDefaultExample
maxvalueintegerrequired
Generate Fibonacci numbers up to this value
-1000
startfromintegeroptional
Start from this position in the sequence
Range: min: 0
Behavior: When combined with a small maxvalue, a sufficiently high startfrom can produce an empty sequence — the maxvalue ceiling is checked after startfrom advances the generator.
--

Response

The Fibonacci Generator API returns responses in JSON, XML, YAML, and CSV formats. The JSON response is shown in the Example section above; alternative formats below.

Other Response Formats

XML Response
200 OK
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>ok</status>
  <error xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  <data>
    <sequence>
      <item>0</item>
      <item>1</item>
      <item>1</item>
      <item>2</item>
      <item>3</item>
      <item>5</item>
      <item>8</item>
      <item>13</item>
      <item>21</item>
      <item>34</item>
    </sequence>
    <count>10</count>
    <start_from>0</start_from>
    <first_value>0</first_value>
    <last_value>34</last_value>
    <sum>88</sum>
    <ratios>
      <ratio>1.666667</ratio>
      <ratio>1.6</ratio>
      <ratio>1.625</ratio>
      <ratio>1.615385</ratio>
      <ratio>1.619048</ratio>
    </ratios>
    <golden_ratio_approximation>1.619048</golden_ratio_approximation>
  </data>
</response>
YAML Response
200 OK
status: ok
error: null
data:
  sequence:
    - 0
    - 1
    - 1
    - 2
    - 3
    - 5
    - 8
    - 13
    - 21
    - 34
  count: 10
  start_from: 0
  first_value: 0
  last_value: 34
  sum: 88
  ratios:
    - 1.666667
    - 1.6
    - 1.625
    - 1.615385
    - 1.619048
  golden_ratio_approximation: 1.619048
CSV Response
200 OK
keyvalue
sequence[0,1,1,2,3,5,8,13,21,34]
count10
start_from0
first_value0
last_value34
sum88
ratios[1.666667,1.6,1.625,1.615385,1.619048]
golden_ratio_approximation1.619048

Response Structure

All API responses follow a consistent structure with the following fields:

FieldTypeDescriptionExample
statusstringIndicates whether the request was successful ("ok") or failed ("error")ok
errorstring | nullContains error message if status is "error", otherwise nullnull
dataobject | nullContains the API response data if successful, otherwise null{...}

Learn more about response formats →

Response Data Fields

When the request is successful, the data object contains the following fields:

FieldTypeSample ValueDescription
sequencearray[0, ...]
Array of generated Fibonacci numbers
Semantics: Length is determined server-side based on maxvalue, not by the caller. May be empty when startfrom advances past maxvalue.
countnumber10
Total count of Fibonacci numbers generated
start_fromnumber0
Starting position in the Fibonacci sequence
first_valuenumber0
First value in the generated sequence
last_valuenumber34
Last value in the generated sequence
sumnumber88
Sum of all numbers in the sequence
ratiosarray[1.666667, ...]
Array of ratios between consecutive sequence values
Semantics: Only the last 5 ratios are returned. Same skip rule for zero denominators. Each value rounded to 6 decimal places.
golden_ratio_approximationnumber1.619048
Approximation of golden ratio from sequence ratios
Semantics: Returns null when no ratios could be computed.

Headers

Only X-API-Key is required. Optional headers include Accept for response format negotiation (JSON, XML, or YAML), User-Agent, and X-Request-ID for request tracing. See all request headers →

GraphQL AccessALPHA

Access Fibonacci Generator through GraphQL to combine it with other API calls in a single request. Query only the fibonacci generator data you need with precise field selection, and orchestrate complex data fetching workflows.

Test Fibonacci Generator in the GraphQL Explorer to confirm availability and experiment with queries.

Credit Cost: Each API called in your GraphQL query consumes its standard credit cost.

GraphQL Endpoint
POST https://api.apiverve.com/v1/graphql
GraphQL Query Example
query {
  fibonaccigenerator(
    input: {
      count: 10
      startfrom: "value"
    }
  ) {
    sequence
    count
    start_from
    first_value
    last_value
    sum
    ratios
    golden_ratio_approximation
  }
}

Note: Authentication is handled via the x-api-key header in your GraphQL request, not as a query parameter.

CORS Support

The Fibonacci Generator API accepts cross-origin requests from any origin, so it can be called directly from browser-based applications without a proxy. See CORS support →

Rate Limiting

Fibonacci Generator requests are throttled per minute on the Free plan and unthrottled on paid plans. Exceeding the limit returns 429 Too Many Requests; rate-limit usage is reported in the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset response headers. See per-plan limits and best practices →

Error Codes

The Fibonacci Generator API uses standard HTTP status codes — 200 on success, 400 for invalid parameters, 401 for missing or invalid keys, 403 for insufficient credits, 429 for rate-limit exhaustion, and 500/503 for server-side issues. Each error response includes an X-Request-ID header you can quote when contacting support. See full error handling guide →

SDKs for Fibonacci Generator

Official Fibonacci Generator packages on npm, PyPI, NuGet, and JitPack — plus a Postman collection and an OpenAPI spec. See the SDK guide →

No-Code Integrations

Fibonacci Generator works with Zapier, Make, Pipedream, n8n, and Power Automate using the same API key. See setup guides →

Troubleshooting

Common issues developers encounter when integrating the Fibonacci Generator API and how to resolve them.

Why does my ratios array only have 5 entries even though my sequence is much longer?

This is intentional. The handler computes a ratio for each consecutive pair of values where the denominator is non-zero, then returns only the last 5 of those ratios via `.slice(-5)`. The earlier ratios are discarded. If you need the full convergence trajectory for analysis or visualization, you'll need to compute it client-side from the sequence array — every value you need is present in the response, the API just doesn't pre-compute and return it.

Why are my large Fibonacci numbers off by a few digits in my JavaScript client?

JavaScript represents all numbers as IEEE 754 doubles, which can only represent integers exactly up to 2^53 − 1 (Number.MAX_SAFE_INTEGER, about 9.007 × 10^15). Fibonacci values exceed this around the 79th position. The API itself computes values in JavaScript Number arithmetic on the server, so the precision ceiling exists end-to-end — values past that point are imprecise as returned, not just as parsed by your client. There is no arbitrary-precision mode. For exact large values, use a different tool or compute them locally with BigInt.

Why am I getting a 400 error when I send count=10.5?

Integer-typed parameters are validated strictly: the request validator rejects any value containing a decimal point with the message 'must be a valid integer (no decimals)'. Pass `Math.floor(value)` or `parseInt(value, 10)` on the client before sending. The same rule applies to startfrom and maxvalue.

How does startfrom map to the standard Fibonacci sequence indexing?

The handler advances its internal state (a, b) forward N times before emission, then begins pushing values of b onto the response sequence. Starting from the initial state (a=0, b=1), this means: startfrom=0 emits [0, 1, 1, 2, 3, 5, ...] (matching F(0), F(1), F(2), ...); startfrom=1 emits [1, 2, 3, 5, ...] (matching F(2), F(3), F(4), ...); startfrom=2 emits [2, 3, 5, ...] (matching F(3), F(4), F(5), ...). In general, the first emitted value with startfrom=N corresponds to F(N+1) for N ≥ 1, and to F(0)=0 for N=0. The leading 0 only appears when startfrom is exactly 0.

Why does my maxvalue request return an empty sequence?

This happens when the first value the generator would emit (after applying startfrom) already exceeds maxvalue. With startfrom=0, this only happens when maxvalue is set to 0 or below — but those are rejected by validation. With a non-zero startfrom, the internal b is already advanced before the first emission, so a sufficiently large startfrom combined with a small maxvalue produces no output. Either lower startfrom, raise maxvalue, or use the count parameter for a guaranteed-non-empty response.

Can I request both count and maxvalue in the same call?

The handler reads both parameters and applies whichever break condition fires first — generation stops when sequence length reaches count OR when the next value would exceed maxvalue. In practice the combined behavior is rarely useful and is not a documented calling mode; pick one or the other.

How precise is the golden_ratio_approximation field?

Six decimal places maximum. Each ratio is rounded via `.toFixed(6)` before being added to the ratios array, and golden_ratio_approximation is just the final entry of that array. If you need higher precision, compute the ratio yourself client-side using sequence[count-1] / sequence[count-2] from the response (subject to the JavaScript Number precision ceiling once values exceed F(79)).

Frequently Asked Questions

How do I get an API key for Fibonacci Generator?
Sign up for a free account at dashboard.apiverve.com. Your API key will be automatically generated and available in your dashboard. The same key works for Fibonacci Generator and all other APIVerve APIs. The free plan includes 1,000 credits plus a 500 credit bonus.
How many credits does Fibonacci Generator cost?

Each successful Fibonacci Generator API call consumes credits based on plan tier. Check the pricing section above for the exact credit cost. Failed requests and errors don't consume credits, so you only pay for successful fibonacci generator lookups.

Can I use Fibonacci Generator in production?

The free plan is for testing and development only. For production use of Fibonacci Generator, upgrade to a paid plan (Starter, Pro, or Mega) which includes commercial use rights, no attribution requirements, and guaranteed uptime SLAs. All paid plans are production-ready.

Can I use Fibonacci Generator from a browser?
Yes! The Fibonacci Generator API supports CORS with wildcard configuration, so you can call it directly from browser-based JavaScript without needing a proxy server. See the CORS section above for details.
What happens if I exceed my Fibonacci Generator credit limit?

When you reach your monthly credit limit, Fibonacci Generator API requests will return an error until you upgrade your plan or wait for the next billing cycle. You'll receive notifications at 80% and 95% usage to give you time to upgrade if needed.

What's Next?

Continue your journey with these recommended resources

Was this page helpful?