Barça API
BlogHow to Integrate Your Backend with a Free Barcelona API in 2026

Published on March 12, 2026

How to Integrate Your Backend with a Free Barcelona API in 2026

Learn how to integrate the free FC Barcelona API into your backend in 2026. Examples in Node.js, Python, and Go — fetch squad, match, and standings data with no API key required.


Backend Integration with the Free Barça API

The Barça API is designed to be consumed from any HTTP client — whether you're building a REST backend, a GraphQL server, a serverless function, or a simple script. This guide covers integration patterns for the most common backend environments.

No API key required. No registration. Completely free.

Base URL and Endpoints

Base URL: https://api.fc-barcelona.app

GET /api/squad              — Full squad (filter: ?position=GK|DF|MF|FW)
GET /api/player/:id         — Single player by ID
GET /api/next-match         — Next scheduled fixture
GET /api/calendar           — Season match calendar
GET /api/standings          — La Liga standings table
GET /api/health             — Health check

All responses are JSON. No authentication headers needed.

Node.js Integration

Using native fetch (Node 18+)

// types
interface Player {
  id: number;
  name: string;
  number: number;
  position: 'GK' | 'DF' | 'MF' | 'FW';
  nationality: string;
  isCaptain: boolean;
}

interface ApiResponse<T> {
  data: T;
}

// fetch squad
async function getSquad(position?: string): Promise<Player[]> {
  const url = new URL('https://api.fc-barcelona.app/api/squad');
  if (position) url.searchParams.set('position', position);

  const res = await fetch(url.toString());
  if (!res.ok) throw new Error(`API error: ${res.status}`);

  const body: ApiResponse<Player[]> = await res.json();
  return body.data;
}

// usage
const forwards = await getSquad('FW');
console.log(`Found ${forwards.length} forwards`);

Using axios

import axios from 'axios';

const client = axios.create({
  baseURL: 'https://api.fc-barcelona.app',
  timeout: 5000,
});

const { data } = await client.get<{ data: Player[] }>('/api/squad', {
  params: { position: 'GK' }
});

const goalkeepers = data.data;

Express.js Route Example

import express from 'express';

const app = express();

app.get('/squad', async (req, res) => {
  try {
    const response = await fetch('https://api.fc-barcelona.app/api/squad');
    const { data } = await response.json();

    // Add your own transformation
    const simplified = data.map((p: Player) => ({
      name: p.name,
      number: p.number,
      position: p.position,
    }));

    res.json(simplified);
  } catch (error) {
    res.status(500).json({ error: 'Failed to fetch squad' });
  }
});

Python Integration

Using requests

import requests
from typing import Optional

BASE_URL = 'https://api.fc-barcelona.app'

def get_squad(position: Optional[str] = None) -> list[dict]:
    params = {'position': position} if position else {}
    response = requests.get(f'{BASE_URL}/api/squad', params=params, timeout=5)
    response.raise_for_status()
    return response.json()['data']

def get_standings() -> list[dict]:
    response = requests.get(f'{BASE_URL}/api/standings', timeout=5)
    response.raise_for_status()
    return response.json()['data']

# usage
forwards = get_squad('FW')
standings = get_standings()

print(f"Top team: {standings[0]['team']} with {standings[0]['points']} points")

Using httpx (async)

import httpx

async def get_next_match():
    async with httpx.AsyncClient() as client:
        response = await client.get('https://api.fc-barcelona.app/api/next-match')
        response.raise_for_status()
        return response.json()['data']

Go Integration

package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

type Player struct {
    ID          int    `json:"id"`
    Name        string `json:"name"`
    Number      int    `json:"number"`
    Position    string `json:"position"`
    Nationality string `json:"nationality"`
    IsCaptain   bool   `json:"isCaptain"`
}

type SquadResponse struct {
    Data []Player `json:"data"`
}

func getSquad() ([]Player, error) {
    resp, err := http.Get("https://api.fc-barcelona.app/api/squad")
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()

    var result SquadResponse
    if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
        return nil, err
    }
    return result.Data, nil
}

func main() {
    players, err := getSquad()
    if err != nil {
        panic(err)
    }
    fmt.Printf("Squad has %d players\n", len(players))
}

Caching Strategy

For production use, add a simple cache to avoid hammering the API and to keep your app responsive:

const CACHE_TTL = 60 * 60 * 1000; // 1 hour in ms
const cache = new Map<string, { data: unknown; ts: number }>();

async function cachedFetch(url: string) {
  const cached = cache.get(url);
  if (cached && Date.now() - cached.ts < CACHE_TTL) {
    return cached.data;
  }

  const res = await fetch(url);
  const data = await res.json();
  cache.set(url, { data, ts: Date.now() });
  return data;
}

Explore First

Before writing integration code, use the interactive terminal to explore the data shape. Check the full API docs for the complete endpoint reference.

Back to blog