get_crime_categories
Obtain valid crime categories for a specified month to filter police.uk crime data accurately. Use this before querying street-level crimes to ensure correct category inputs.
Instructions
Retrieve valid crime categories for a given date
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Specific month (YYYY-MM) |
Implementation Reference
- src/index.ts:333-337 (handler)The handler function for get_crime_categories. Calls the police.uk API endpoint 'crime-categories' with an optional date parameter.
async function getCrimeCategories(args: any) { const { date } = args; const params = date ? { date } : {}; return await makeApiRequest('crime-categories', params) || []; } - src/index.ts:78-87 (schema)Input schema definition for get_crime_categories. Accepts a single optional 'date' parameter (YYYY-MM format).
{ name: 'get_crime_categories', description: 'Retrieve valid crime categories for a given date', inputSchema: { type: 'object', properties: { date: { type: 'string', description: 'Specific month (YYYY-MM)' } } } }, - src/index.ts:452-452 (registration)Registration of get_crime_categories in the toolFunctions mapping, connecting the tool name to its handler function.
get_crime_categories: getCrimeCategories, - src/index.ts:9-20 (helper)The makeApiRequest helper function used by getCrimeCategories to make HTTP GET requests to the police.uk API.
async function makeApiRequest(endpoint: string, params?: Record<string, any>) { const baseUrl = 'https://data.police.uk/api'; const url = `${baseUrl}/${endpoint}`; try { const response = await axios.get(url, { params, timeout: 10000 }); return response.data; } catch (error) { console.error(`API request failed: ${error}`); return null; } }