Excel and CSV

Turn an Excel or CSV file into a REST API

A lot of small businesses run on a spreadsheet. We took one that looks like the real thing, a workshop schedule kept in Excel plus a list of venues exported as CSV, and turned both into a REST API with search, date filters and facet counts. Then we did what actually happens a week later: someone edits the sheet, and the API has to catch up. Here's how that went, including the rows that didn't make it.

1,347
rows in the Excel sheet
1,341
imported on the first run
~1 s
per import
+38
sessions added by the update

The sample files

Makers Studio runs craft and cooking workshops in 47 venues across the UK. The data is generated, but it was typed the way people type into spreadsheets: a few dates entered as text, "TBC" where nobody knew the date yet, empty cells, and some level values in lowercase.

FileRowsWhat's in it
venues.csv47Semicolon-separated, as Excel saves it with a European locale. Two venues are both called "The Old Library", one in Bristol and one in York.
workshops.xlsx1,347One row per workshop session. 16 dates typed as dd/mm/yyyy text, 6 marked TBC, 44 empty Seats Left cells, 25 lowercase levels.
workshops-update.xlsx1,385The same sheet a week later: 75 price changes, 14 cancellations, 38 new sessions.

Download them if you want to follow along:

Import the two files

Each file becomes one model with its own endpoint. Venues go first, because workshops point to them. The screens are described in Data import and shown in Guide 11.

  1. Create an API, then open Data Import and choose Create New Model + Mapping + Endpoint.
  2. Upload venues.csv with CSV Delimiter set to ;. Mark venue_code as the primary key, and name and city as Visible In Related Model so workshops can carry them.
  3. Start a second import with workshops.xlsx and choose DD/MM/YYYY as the date order of start_date. Mark ref as the primary key and link venue_code to the venues model.
  4. Assign an API key to both endpoints and deploy the version.

Both imports finished in about a second each. The venues came through complete; the workshops didn't, more on that below.

What we changed in the mapping

SearchAPI reads the header row and suggests a name and a type for every column. Most suggestions were fine. These are the ones we touched.

Headers become field names

Workshop Title turns into workshop_title, Price (£) into price. These are the names you filter on, as in ?price[to]=60, so rename them here if you need to.

Codes and categories should be keyword

A text column comes in as text, which is right for titles and descriptions: they're searched by word. For ref, category, level, status and city we wanted exact values, and facet counts, so we switched them to keyword. Keep in mind a keyword match is case-sensitive: status=cancelled finds nothing, only status=Cancelled does. The step-free access column, all "Yes" and "No", was detected as boolean without our help.

Set the date column to date

Because of the six "TBC" cells, the suggested type for start_date was text. We set it to date anyway, since we wanted to filter by date range. Real Excel dates come through as 2027-04-21, and so do dates typed as text, like 28/04/2027.

A date field also asks for a date order, and there's no default. It matters for text dates that fit both readings: 11/09/2027 is November 9 as MM/DD/YYYY and September 11 as DD/MM/YYYY. Our sheet was written in the UK, so we chose DD/MM/YYYY.

Link workshops to venues

We set venue_code to object, chose the venues model as the relation and renamed the field to venue. Each workshop now carries the venue's name and city, the fields we had marked Visible In Related Model on the venues import.

Pick the aggregations

On workshops we chose category, level, status, venue.city and venue.name. These can't be added after the version is published, so it pays to decide here.

Six rows that didn't make it

The workshops import ended with 1,341 of 1,347 rows. The job page lists the other six, and they're exactly the ones we expected:

Row 424 · WS-1422
Invalid date value: "TBC". Supported formats: YYYY-MM-DD (e.g. 2024-03-15),
MM/DD/YYYY (e.g. 03/15/2024), DD/MM/YYYY (e.g. 15/03/2024)

A date field can't hold "TBC", so the row is skipped and the rest of the file carries on. We'd rather leave the cell empty in the sheet; an empty date is accepted and simply comes back as null. The empty Seats Left cells were handled the same way.

Search and filter the schedule

Here are a few requests a booking page would send, made with a read-only key. All parameters are described in Using your API. JSON filter values are shown unencoded to keep them readable; URL-encode them in real requests.

One workshop by its reference

The primary key from the sheet is the id in the URL. This is one of the rows whose date was typed as text:

GET https://makers.searchapi.net/workshops/v1/workshops/WS-1022
X-API-KEY: your-read-key
{
  "ref": "WS-1022",
  "workshop_title": "Candle Making",
  "category": "Crafts",
  "instructor": "Ben Walsh",
  "start_date": "2027-04-28",
  "start_time": "10:30",
  "duration_hrs": 4,
  "price": 60,
  "seats": 10,
  "seats_left": 4,
  "level": "Beginner",
  "status": "Scheduled",
  "description": "Candle Making with Tannery Studio, Oxford. Materials included.",
  "venue": { "venue_code": "VEN-043", "name": "Tannery Studio", "city": "Oxford" }
}

Search by word

GET /workshops/v1/workshops?q=sourdough&includes=ref,workshop_title,start_date,price,venue

36 sessions of "Sourdough Basics" in different cities, the first one in Cardiff on 30 June 2027 for £55.

Baking workshops in May, by date

GET /workshops/v1/workshops?category=Baking&start_date[from]=2027-05-01&start_date[to]=2027-05-31&sort=start_date&includes=ref,workshop_title,category,start_date,price,venue
"pagination": { "start": 0, "limit": 10, "count": 10, "total": 15, … },
"results": [
  { "ref": "WS-2259", "workshop_title": "Laminated Pastry", "category": "Baking", "start_date": "2027-05-03",
    "price": 55, "venue": { "venue_code": "VEN-022", "name": "Mill Yard", "city": "Leeds" } },
  { "ref": "WS-1553", "workshop_title": "Laminated Pastry", "category": "Baking", "start_date": "2027-05-03",
    "price": 55, "venue": { "venue_code": "VEN-022", "name": "Mill Yard", "city": "Leeds" } },
  …
]

Workshops in York that still have seats

GET /workshops/v1/workshops?venue={"city":"York"}&seats_left[from]=1

118 sessions. The city lives in the venues file, not in the workshops sheet; the filter works because every workshop carries its venue.

Two venues with the same name

This is where keeping the venue code pays off. Filter by name and you get workshops from both Old Libraries:

GET /workshops/v1/workshops?venue={"name":"The Old Library"}
"aggregations": {
  "venue_name": {
    "buckets": [
      { "key": "The Old Library|VEN-001", "doc_count": 28 },
      { "key": "The Old Library|VEN-031", "doc_count": 23 }
    ]
  },
  "venue_city": {
    "buckets": [
      { "key": "Bristol|VEN-001", "doc_count": 28 },
      { "key": "York|VEN-031", "doc_count": 23 }
    ]
  },
  …
}

Facets on a related field come back as value|id. The name alone would show "The Old Library" twice with no way to tell which is which; the code tells you, and it's what you filter on next: venue={"venue_code":"VEN-031"} leaves the 23 in York.

Lowercase values split a facet

The level facet over all workshops looked like this:

"level": {
  "buckets": [
    { "key": "Beginner", "doc_count": 547 },
    { "key": "Intermediate", "doc_count": 414 },
    { "key": "All levels", "doc_count": 391 },
    { "key": "beginner", "doc_count": 12 },
    { "key": "all levels", "doc_count": 9 },
    { "key": "intermediate", "doc_count": 6 }
  ]
}

Keyword values are stored exactly as typed, so "beginner" and "Beginner" show up as two separate options. The import doesn't warn about it. To prevent it, restrict the column to a fixed list in Excel (Data → Data Validation → List). To fix rows already in the API, correct the cells and import the file into the same model again; rows are matched on ref, so the corrected values replace the old ones.

Update the API from a new version of the sheet

A week later the sheet had changed: prices went up on 75 sessions, 14 were cancelled and 38 new ones were added. We didn't create anything new. We imported workshops-update.xlsx into the same model:

  1. In Data Import, choose Import Into Existing Model and select the workshops model.
  2. Upload the new file, check the column for each field and choose DD/MM/YYYY for start_date again.
  3. Start the import.

The second step needed one manual choice. In the model the relation field is called venue, while the column in the sheet is still Venue Code, so it wasn't matched automatically. We picked venue_code for it; every other field matched by name.

Rows are matched on the primary key. A ref that's already there is updated, a new one is added, and nothing is duplicated:

BeforeAfter
WS-1065 price5560
WS-1065 seats left86
WS-1009 statusScheduledCancelled
WS-2347404 Record not foundStained Glass Suncatcher, 3 Aug 2027, The Old Library, York
Total workshops1,3411,379

1,341 plus 38 new is 1,379. The six "TBC" rows were still in the file and were skipped again, which is a good reminder to fix them in the sheet rather than in the API. The status facet now shows Scheduled 1,365 and Cancelled 14, so the booking page can hide cancelled sessions with status=Scheduled.

That's also why we cancel with a status instead of deleting the row. An import adds and updates; it doesn't remove records that are missing from the file.

Where it falls short

Frequently asked questions

Which file formats can I import?
CSV with any single-character delimiter, XLSX, and archives of those files. For XLSX, the first sheet is read.
How do I update the API when the spreadsheet changes?
Import the new file with Import Into Existing Model. Rows are matched on the primary key: rows that already exist are updated, new ones are added.
Does a row I delete from the spreadsheet disappear from the API?
No. An import only adds and updates records. Delete records through the API DELETE endpoint or in Data UI, or keep them and mark them with a status column instead.
Why are some rows missing after the import?
Rows that fail validation, such as a date column holding "TBC", are skipped. The import job lists each one with its row number, primary key and the reason.

Other use cases

All use cases

Try it with your own spreadsheet

The free Starter plan is enough for a sheet this size. Upload it under Data Import and keep the Data import docs open next to it.

Create a free account