Battery Code Decoder API

A free REST API that decodes Chinese GB/T-standard battery traceability codes into manufacturer, chemistry, capacity, voltage and production date. Use GET /api/battery/decode?code=… for simple browser, spreadsheet or agent calls, or POST /api/decode to send the code in a JSON body — both return the same fields. Rate limit: 100 requests per 15 minutes per IP. Prefer no code? Try the embeddable widget or decode a code on the site.

cURL Examples

Test the API directly from your terminal or command line:

POST Request

# POST request with JSON body
curl -X POST https://api.batterydays.com/api/decode \
  -H "Content-Type: application/json" \
  -d '{"code":"02YCB65212100JB970000657"}'

# Example response (only fields with valid data, excludes N/A fields):
# {
#   "manufacturer": "EVE",
#   "productType": "Single battery",
#   "batteryType": "LiFePO4 Battery",
#   "productionDate": "2021-09-07",
#   "nominalCapacity": "105Ah(LF105)",
#   "nominalVoltage": "3.2V",
#   "manufacturerWebsite": "https://www.evebattery.com"
# }

GET Request

# GET request with query parameter
curl "https://api.batterydays.com/api/battery/decode?code=02YCB65212100JB970000657"

# Example response (only fields with valid data, excludes N/A fields):
# {
#   "manufacturer": "EVE",
#   "productType": "Single battery", 
#   "batteryType": "LiFePO4 Battery",
#   "productionDate": "2021-09-07",
#   "nominalCapacity": "105Ah(LF105)",
#   "nominalVoltage": "3.2V",
#   "manufacturerWebsite": "https://www.evebattery.com"
# }

JavaScript Example

// Example: Using the Battery Days API with JavaScript fetch
  
const fetchBatteryData = async (code) => {
  try {
    const response = await fetch('https://api.batterydays.com/api/decode', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ code }),
    });
    
    if (!response.ok) {
      throw new Error('API request failed');
    }
    
    return await response.json();
  } catch (error) {
    console.error('Error decoding battery code:', error);
    throw error;
  }
};

// Usage example
fetchBatteryData('02YCB65212100JB970000657')
  .then(data => console.log(data))
  .catch(error => console.error(error));

Google Sheets Example

Setup Instructions

Follow these steps to add the Battery Decoder function to your Google Sheet:

  1. Open your Google Sheet
  2. Go to ExtensionsApps Script
  3. Delete any existing code in the editor
  4. Paste the code below into the Apps Script editor
  5. Click Save (Ctrl+S or Cmd+S)
  6. Return to your Google Sheet and use the formula as shown in the examples
// Google Apps Script example for Google Sheets
  
function BATTERYCODE(code, field) {
  const url = 'https://api.batterydays.com/api/decode';
  
  const options = {
    'method': 'post',
    'contentType': 'application/json',
    'payload': JSON.stringify({ code })
  };
  
  try {
    const response = UrlFetchApp.fetch(url, options);
    const data = JSON.parse(response.getContentText());
    
    // API returns only fields with valid data (excludes N/A fields)
    
    // If specific field is requested, return that field's value
    if (field) {
      return data[field] || "Field not found";
    }
    
    // If no field specified, return all available values as horizontal array
    // Note: API already filters out N/A values, so we get all valid fields
    const values = Object.values(data).filter(value => value && value !== 'N/A');
    
    // Return as horizontal array (1 row, multiple columns)
    return [values];
    
  } catch (error) {
    return field ? error.toString() : [["Error: " + error.toString()]];
  }
}

Available Field Names

Use these field names as the 2nd parameter to get specific data:

  • "manufacturer"
  • "productType"
  • "batteryType"
  • "productionDate"
  • "nominalCapacity"
  • "nominalVoltage"
  • "manufacturerWebsite"

Usage Examples

After setting up the script, you can use the BATTERYCODE formula directly in your sheet cells:

Type this formula in any cell to get the manufacturer:
=BATTERYCODE("02YCB65212100JB970000657", "manufacturer")
Result: "EVE"
Type this formula to get the battery type:
=BATTERYCODE("02YCB65212100JB970000657", "batteryType")
Result: "LiFePO4 Battery"
Type this formula to get the production date:
=BATTERYCODE("02YCB65212100JB970000657", "productionDate")
Result: "2021-09-07"
Type this formula to get all data (will spread across multiple columns):
=BATTERYCODE("02YCB65212100JB970000657")
Result: All valid battery data spread across columns A, B, C, etc.

Tip: You can reference battery codes from other cells too! For example, if cell A1 contains a battery code, use: =BATTERYCODE(A1, "manufacturer")