Skip to content
Open

Main #537

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
# Project Express API

Replace this readme with your own information about your project.
This API is part of my final project, which focuses on tracking allowances abroad for business trips. It provides standardized allowance amounts for various countries in the years 2023 and 2024.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
**Note:** This API **does not** automatically map cities to their corresponding countries. It only stores and returns data at the country-level. In a broader application (like my final project), an additional step or a separate database would be needed to link a given city to the correct country before querying this API.

## The problem
## Background

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?
In creating trip reports, users may eventually need to specify the trip’s location, which includes both the city and country. While this API doesn’t handle city-to-country determination, it can return the relevant allowance ("traktamente" in Swedish) once you know the country.

The allowance data comes from the Swedish Tax Agency’s public dataset ([Skatteverket](https://skatteverket.entryscape.net/rowstore/dataset/70ccea31-b64c-4bf5-84c7-673f04f32505/json)).

## Endpoints & Parameters

The API provides an endpoint that lets you filter allowances by both country and year.

- **Country (String):**
Supports partial matches. For example, `?country=tobago` will return data for "Trinidad and Tobago" because "tobago" is a substring of the full country name.
(OBS! complete the name of USA, UK, UAE, PRC in traktamente-en.json)

- **Year (String):**
Matches must be exact. For example, `?year=2024` returns data for 2024 allowances only.

You can use these parameters separately or combine them for more specific filtering.

## Technical Details

- **Case-Insensitive Country Matching:**
The API converts all country names and the search query to lowercase, ensuring that "South Korea", "south korea", and "SOUTH KOREA" are treated the same.

- **Partial Matching with `.includes()`:**
For the country parameter, `.includes()` is used. Substring matches will return relevant records.

- **Strict Equality for Year:**
The year filter uses strict equality (`===`) so that only exact year matches are returned.

- **Cumulative Filtering:**
If you provide both `country` and `year`, the results will be filtered by both conditions.
Example: `?country=tobago&year=2024` returns results matching "tobago" and the year 2024.

## Example Requests

- **All allowances for 2023**:
`GET /traktamente?year=2023`

- **Allowances for countries containing "tobago"**:
`GET /traktamente?country=tobago`

- **Combine both parameters**:
`GET /traktamente?country=tobago&year=2024`

## View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
https://traktamente-express-api.onrender.com
Loading