# List all Location Definitions GET https://api.trebellar.app/api/v2/locations Reference: https://docs.trebellar.app/api-reference/api-resources/assets/list-locations ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: API version: 1.0.0 paths: /api/v2/locations: get: operationId: list-locations summary: List all Location Definitions tags: - subpackage_assets parameters: - name: X-Trebellar-Api-Key in: header required: true schema: type: string responses: '200': description: Successful operation content: application/json: schema: $ref: '#/components/schemas/ListLocationsResponse' '500': description: Internal Server Error content: application/json: schema: $ref: '#/components/schemas/ErrorSchema' servers: - url: https://api.trebellar.app components: schemas: LocationDefinitionType: type: string enum: - region - sub-region - area - city - site - campus title: LocationDefinitionType LocationDefinitionStatus: type: string enum: - active - archived default: active title: LocationDefinitionStatus LocationDefinition: type: object properties: id: type: string name: type: string type: $ref: '#/components/schemas/LocationDefinitionType' parentId: type: string status: $ref: '#/components/schemas/LocationDefinitionStatus' required: - id - name - type description: A location definition within the organization hierarchy title: LocationDefinition ListLocationsResponse: type: object properties: data: type: array items: $ref: '#/components/schemas/LocationDefinition' required: - data description: Response containing all location definitions title: ListLocationsResponse ErrorSchema: type: object properties: code: type: number format: double message: type: string error: type: string details: type: object additionalProperties: description: Any type required: - code - message description: Common Error Schema title: ErrorSchema securitySchemes: apiKey: type: apiKey in: header name: X-Trebellar-Api-Key bearerAuth: type: http scheme: bearer ``` ## SDK Code Examples ```typescript import { TrebellarApiClient } from "@trebellar/api-sdk"; async function main() { const client = new TrebellarApiClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.assets.listLocations(); } main(); ``` ```python from trebellar import TrebellarApi client = TrebellarApi( api_key="YOUR_API_KEY_HERE", ) client.assets.list_locations() ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.trebellar.app/api/v2/locations" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Trebellar-Api-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.trebellar.app/api/v2/locations") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Trebellar-Api-Key"] = '' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.trebellar.app/api/v2/locations") .header("X-Trebellar-Api-Key", "") .asString(); ``` ```php request('GET', 'https://api.trebellar.app/api/v2/locations', [ 'headers' => [ 'X-Trebellar-Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.trebellar.app/api/v2/locations"); var request = new RestRequest(Method.GET); request.AddHeader("X-Trebellar-Api-Key", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["X-Trebellar-Api-Key": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://api.trebellar.app/api/v2/locations")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```