You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/image-url.jpg%20%22Optional%20title%22?q=api&page=25&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=api
Returns an array of strings in format "username" or "username/projectName"
Found 11829 results for "api"(553ms)
64};
6566const API_INFO = {
67name: "Simple Scrabble API",
68version: "1.0.0",
69description: "A simple API to provide data for determining if a given scrabble board is valid.",
70endpoints: [
71{
147JSON.stringify({
148error: "Route not found",
149message: "Visit the root endpoint (/) for API documentation",
150}),
151{
214const baseUrl = `${url.protocol}//${url.host}`;
215216const apiInfo = {
217...API_INFO,
218example: `curl -X GET ${baseUrl}/ | jq .`,
219};
220221return new Response(JSON.stringify(apiInfo, null, 2), {
222headers: {
223"Content-Type": "application/json",
4445/**
46* Configuration options for the Geocoding API
47*/
48interface GeocodingAPIOptions {
49apiKey?: string;
50baseUrl?: string;
51}
5253/**
54* Geocoding API that converts location strings to latitude/longitude coordinates
55* with support for different granularity levels
56*/
57class GeocodingAPI {
58private apiKey: string | null;
59private baseUrl: string;
60private granularities: GranularityLevel[];
6162constructor(options?: GeocodingAPIOptions) {
63this.apiKey = options?.apiKey || null;
64this.baseUrl = options?.baseUrl || "https://api.geocode.earth/v1";
65this.granularities = [
66"address",
86}
8788// In a real implementation, this would make an actual API request
89// Here we're simulating the API response
90const params = new URLSearchParams({
91text: location,
92layers: granularity,
93api_key: this.apiKey || "demo_key",
94});
95115116/**
117* Simulate API response for demonstration purposes
118* @private
119*/
120private _simulateResponse(location: string, granularity: GranularityLevel): GeocodingResult {
121// This would be replaced by actual API responses in production
122const mockResponses: Record<string, Record<GranularityLevel, MockLocationData>> = {
123"New York, NY": {
174175/**
176* Extended Geocoding API with additional features
177*/
178class EnhancedGeocodingAPI extends GeocodingAPI {
179/**
180* Batch geocode multiple locations
201*/
202async reverseGeocode(lat: number, lng: number, granularity: GranularityLevel = "address"): Promise<GeocodingResult> {
203// In a real implementation, this would make an API request
204// Here we're just returning a simulated response
205return {
223224// Usage example:
225// const api = new EnhancedGeocodingAPI({ apiKey: "your_api_key" });
226// const result = await api.geocode("New York, NY", "locality");
227// const batchResults = await api.batchGeocode({
228// locations: ["New York, NY", "Los Angeles, CA"],
229// granularity: "locality"