Skip to content

API Usage

patent-ed edited this page Mar 14, 2026 · 1 revision

Using the Data (API)

All data in this repository is free to download and use under the CC BY 4.0 license.

Download a CSV

Click any CSV file in the repository and use the "Download raw file" button, or clone the entire repo:

git clone https://github.com/AVSOPS/veteran-organizations.git

Raw File URLs

GitHub serves raw CSV files directly. Use these URLs in your code:

https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/headquarters.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/vfw/local-posts.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/vfw/state-departments.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/legion/local-posts.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/legion/state-departments.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/dav/local-chapters.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/fra/local-branches.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/other/state-departments.csv
https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/war-periods.csv

Python Examples

Load and filter VFW posts

import pandas as pd

vfw = pd.read_csv("https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/vfw/local-posts.csv")

# All VFW posts in Indiana
indiana_vfw = vfw[vfw["state"] == "IN"]
print(f"Indiana VFW posts: {len(indiana_vfw)}")

# Posts with hall rental
halls = vfw[vfw["hall_rental"] == True]
print(f"Posts with hall rental: {len(halls)}")

Combine all organizations

import pandas as pd

files = {
    "VFW Posts": "vfw/local-posts.csv",
    "Legion Posts": "legion/local-posts.csv",
    "DAV Chapters": "dav/local-chapters.csv",
    "FRA Branches": "fra/local-branches.csv",
}

base = "https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/"

for name, path in files.items():
    df = pd.read_csv(base + path)
    print(f"{name}: {len(df)} records")

Find organizations near a location

import pandas as pd
from math import radians, cos, sin, asin, sqrt

def haversine(lat1, lon1, lat2, lon2):
    """Distance in miles between two GPS coordinates."""
    lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])
    dlat = lat2 - lat1
    dlon = lon2 - lon1
    a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
    return 2 * 3956 * asin(sqrt(a))

# Load VFW posts
vfw = pd.read_csv("https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/vfw/local-posts.csv")

# Find posts within 25 miles of Indianapolis (39.7684, -86.1581)
vfw_with_coords = vfw.dropna(subset=["latitude", "longitude"])
vfw_with_coords["distance"] = vfw_with_coords.apply(
    lambda r: haversine(39.7684, -86.1581, r["latitude"], r["longitude"]), axis=1
)
nearby = vfw_with_coords[vfw_with_coords["distance"] <= 25].sort_values("distance")
print(nearby[["title", "city", "state", "distance"]].head(10))

JavaScript Example

// Fetch VFW posts and filter by state
const response = await fetch(
  "https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/vfw/local-posts.csv"
);
const text = await response.text();
const rows = text.split("\n").slice(1); // skip header

const ohioPosts = rows.filter(row => {
  const cols = row.split(",");
  return cols[8] === "OH"; // state column
});

console.log(`Ohio VFW posts: ${ohioPosts.length}`);

R Example

library(readr)

vfw <- read_csv("https://raw.githubusercontent.com/AVSOPS/veteran-organizations/main/vfw/local-posts.csv")

# Posts by state
table(vfw$state)

# Posts with funeral honors
sum(vfw$funeral_honors == TRUE, na.rm = TRUE)

Rate Limits

GitHub raw file URLs are subject to GitHub's standard rate limits. For heavy usage, clone the repository locally rather than fetching files on every request.

Attribution

When using this data, please credit AVSOPS:

Data provided by AVSOPS — a 501(c)(3) nonprofit open data initiative.

Clone this wiki locally