### Get Inventory List using Node.js Source: https://apidocs.macrofab.com/reference/inventory This Node.js example shows how to retrieve inventory items using the 'axios' library. It makes a GET request to the MacroFab API endpoint and handles the JSON response. Ensure 'axios' is installed (`npm install axios`). ```javascript const axios = require('axios'); const getInventory = async () => { try { const response = await axios.get('https://api.macrofab.com/api/v2/inventory', { headers: { 'accept': 'application/json' } }); console.log(response.data); return response.data; } catch (error) { console.error('Error fetching inventory:', error); } }; getInventory(); ``` -------------------------------- ### Get Inventory List using PHP Source: https://apidocs.macrofab.com/reference/inventory This PHP example demonstrates fetching inventory data using cURL. It sets up a cURL session, specifies the GET request to the MacroFab API endpoint, and includes the 'accept' header. The response is then decoded from JSON. ```php ``` -------------------------------- ### Get Order List using Node.js Source: https://apidocs.macrofab.com/reference/orders-1 This Node.js example shows how to make a GET request to the Macrofab API to retrieve a list of orders. It utilizes the 'node-fetch' library for making HTTP requests and handles the JSON response. ```javascript const fetch = require('node-fetch'); const url = 'https://api.macrofab.com/api/v2/orders'; fetch(url, { method: 'GET', headers: { 'accept': 'application/json' } }) .then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); }) .then(data => { console.log(data); }) .catch(error => { console.error('Error fetching orders:', error); }); ``` -------------------------------- ### Example API Response for Product and Test Data Source: https://apidocs.macrofab.com/reference/post_api-v1-testbench-results Provides a concrete example of the JSON response structure for a product and its test results. This illustrates how the defined schema is populated with actual data. ```json { "batch": 1, "counter": 6, "device_created": "2024-05-13 16:11:36.479405", "device_id": "k39tn9", "itar_restricted": false, "organization_id": "md1tnk", "organization_name": "MacroFab", "product_name": "Test Product", "product_revision": 1, "product_sku": "08-0000-01", "results": { "created": "2024-05-13 16:11:36.479405", "location_id": "MacroFab HQ", "result": { "test_results": { "test_results": { "device_id": "k39tn9", "organization_id": "md1tnk", "product_name": "Test Product", "product_sku": "08-0000-01", "product_revision": 1, "batch": 1, "serial_number": "3E1B9FBDFAC5", "location_id": "MacroFab HQ", "station": "Programming", "status": "PASS", "results": { "temperature": 25 }, "created": "2024-05-13 16:11:36.479405" } } }, "station": "Programming", "status": "PASS", "test_result_id": "k39tn9", "user_id": "k1vtjm" }, "serial_number": "3E1B9FBDFAC5" } ``` -------------------------------- ### Sign S3 Upload API Examples Source: https://apidocs.macrofab.com/reference/pcb Provides code examples for interacting with the Sign S3 Upload API. These examples cover common programming languages used for web development, allowing developers to integrate file upload functionality into their applications. ```javascript // Node.js Example (Conceptual) // Requires a library like 'axios' or 'node-fetch' async function getS3UploadSignature(filename, uploadType, pcbId, pcbRevision) { const url = 'https://api.macrofab.com/api/v2/sign_s3_upload'; const headers = { 'accept': 'application/json' // Add any necessary authentication headers here }; const params = { filename: filename, upload_type: uploadType, pcb_id: pcbId, pcb_revision: pcbRevision }; try { // const response = await axios.get(url, { headers: headers, params: params }); // return response.data; console.log('Simulating API call with:', { url, headers, params }); // Replace with actual API call return { "upload_url": "https://example.com/signed-upload-url", "filename": filename }; } catch (error) { console.error('Error getting S3 upload signature:', error); throw error; } } // Example Usage: // getS3UploadSignature('my_pcb_design.zip', 'pcb', '12345', 1) // .then(data => console.log('Signature received:', data)) // .catch(err => console.error('Failed to get signature')); ``` ```ruby # Ruby Example (Conceptual) # Requires a library like 'net/http' or 'httparty' require 'net/http' require 'uri' def get_s3_upload_signature(filename, upload_type, pcb_id, pcb_revision) uri = URI.parse('https://api.macrofab.com/api/v2/sign_s3_upload') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) request['accept'] = 'application/json' # Add any necessary authentication headers here params = { filename: filename, upload_type: upload_type, pcb_id: pcb_id, pcb_revision: pcb_revision } uri.query = URI.encode_www_form(params) begin response = http.request(request) return JSON.parse(response.body) rescue => e puts "Error getting S3 upload signature: #{e.message}" raise e end end # Example Usage: # signature_data = get_s3_upload_signature('my_design.gerber', 'pcb', '67890', 2) # puts "Signature data: #{signature_data}" ``` ```php $filename, 'upload_type' => $upload_type, 'pcb_id' => $pcb_id, 'pcb_revision' => $pcb_revision ]; $url .= '?' . http_build_query($params); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Accept: application/json' // Add any necessary authentication headers here ]); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); curl_close($ch); return false; } curl_close($ch); return json_decode($response, true); } // Example Usage: // $signature_data = get_s3_upload_signature('board_layout.gbr', 'pcb', '11223', 3); // if ($signature_data) { // print_r($signature_data); // } ?> ``` ```python # Python Example (Conceptual) # Requires the 'requests' library import requests def get_s3_upload_signature(filename, upload_type, pcb_id, pcb_revision): url = 'https://api.macrofab.com/api/v2/sign_s3_upload' headers = { 'accept': 'application/json' # Add any necessary authentication headers here } params = { 'filename': filename, 'upload_type': upload_type, 'pcb_id': pcb_id, 'pcb_revision': pcb_revision } try: response = requests.get(url, headers=headers, params=params) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error getting S3 upload signature: {e}") raise # Example Usage: # try: # signature_data = get_s3_upload_signature('my_design.dxf', 'pcb', '44556', 4) # print(f"Signature data: {signature_data}") # except Exception as e: # print("Failed to get signature.") ``` -------------------------------- ### API Authentication Example Source: https://apidocs.macrofab.com/index Demonstrates how to include the API key as a URL parameter for authentication when accessing the MacroFab API. This is a fundamental step for all API requests. ```url https://api.macrofab.com/api/v2/{endpoint}?apikey=abcedefgh ``` -------------------------------- ### Get Inventory List using Python Source: https://apidocs.macrofab.com/reference/inventory This Python snippet uses the 'requests' library to make a GET request to the MacroFab inventory API. It includes the necessary 'accept' header and prints the JSON response. Ensure the 'requests' library is installed (`pip install requests`). ```python import requests url = "https://api.macrofab.com/api/v2/inventory" headers = { "accept": "application/json" } try: response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes inventory_data = response.json() print(inventory_data) except requests.exceptions.RequestException as e: print(f"Error fetching inventory: {e}") ``` -------------------------------- ### Get User Information (cURL) Source: https://apidocs.macrofab.com/reference/users-and-organizations Example of how to get user information using cURL. This request requires the user's email address as a path parameter and an 'accept' header for JSON response. ```shell curl --request GET \ --url https://api.macrofab.com/user/email \ --header 'accept: application/json' ``` -------------------------------- ### GET /products Source: https://apidocs.macrofab.com/reference/post_api-v1-testbench-results-search Retrieves a list of products with optional filtering and pagination. Includes product details, SKU attributes, and test results. ```APIDOC ## GET /products ### Description Retrieves a list of products with optional filtering and pagination. This endpoint returns detailed product information, including SKU attributes and test results. ### Method GET ### Endpoint /products ### Query Parameters - **offset** (integer) - Optional - Offset for Search Results - **limit** (integer) - Optional - Limit for Search Results ### Response #### Success Response (200) - **product_revision** (integer) - Product Revision - **product_sku** (string) - Product SKU - **results** (object) - Test Results - **created** (string) - Test Date - **location_id** (string) - Location ID - **result** (object) - Test Result Data - **station** (string) - Test Station - **status** (string) - Test Status - **test_result_id** (string) - Test Result ID - **user_id** (string) - User ID - **sku_attributes** (array) - SKU Attributes - **attributes** (object) - SKU Attributes - **organization_id** (string) - Organization ID - **product_sku** (string) - Product SKU - **updated** (string) - SKU Update Date - **updated_by** (string) - SKU Update User - **offset** (integer) - Offset for Search Results - **limit** (integer) - Limit for Search Results - **record_count** (integer) - Total Record Count #### Response Example ```json { "product_revision": 1, "product_sku": "08-0000-01", "results": { "created": "2024-05-13 16:11:36.479405", "location_id": "MacroFab HQ", "result": {}, "station": "Programming", "status": "PASS", "test_result_id": "k39tn9", "user_id": "k1vtjm" }, "sku_attributes": [ { "attributes": {}, "organization_id": "md1tnk", "product_sku": "08-0000-01", "updated": "2024-05-13 16:11:36.479405", "updated_by": "k1vtjm" } ], "offset": 0, "limit": 25, "record_count": 100 } ``` ``` -------------------------------- ### Get User Information (PHP) Source: https://apidocs.macrofab.com/reference/users-and-organizations Example of how to get user information using PHP. This request requires the user's email address and an 'accept' header for JSON response. It uses cURL for making HTTP requests. ```php ``` -------------------------------- ### Example PCB Data Structure Source: https://apidocs.macrofab.com/reference/get_api-v2-pcb-pcb-id This JSON snippet illustrates the structure of PCB data, including manufacturing specifications, impedance control, thickness, and other properties. It serves as a reference for data representation within the API. ```json { "impedance_control": { "0": 0, "1": 120 }, "manufacturing": { "Extended": 120, "Extended Drill": 120, "Extended/Extended Drill": 240, "Standard": 0 }, "thickness": { "2": { "max": 6.3, "min": 0.2 }, "4": { "max": 6.3, "min": 0.4 }, "6": { "max": 6.3, "min": 0.6 }, "8": { "max": 6.3, "min": 1 } } } ``` -------------------------------- ### Create PCB Project using OpenAPI Source: https://apidocs.macrofab.com/reference/post_api-v2-pcb This OpenAPI definition outlines the process for creating a new PCB project. It specifies the request body format, which includes the project name and a short description. The response includes the PCB ID and URI upon successful creation. ```json { "openapi": "3.0.1", "info": { "title": "MacroFab API", "description": "MacroFab API", "version": "1.0.0" }, "servers": [ { "url": "https://api.macrofab.com/" } ], "paths": { "/api/v2/pcb": { "post": { "tags": [ "PCB" ], "summary": "Create PCB Project", "description": "Create a new PCB Project.\n\nYou can specify the name of the PCB project and the short description of the project using a single JSON object passed as the body of the request. Responds with the full object definition of the PCB upon successful creation.\n", "requestBody": { "content": { "application/json": { "example": { "pcb": { "name": "The new name of the PCB", "short": "The new short description of the PCB" } }, "schema": { "type": "object", "properties": { "pcb": { "type": "object", "properties": { "name": { "type": "string", "description": "The new name of the PCB", "example": "The new name of the PCB" }, "short": { "type": "string", "description": "The new short description of the PCB", "example": "The new short description of the PCB" } } } } } } }, "required": false }, "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "example": { "pcb": { "pcb_id": "kpqt9m", "uri": "/pcb/kpqt9m" } } } } } } }, "security": [ { "apikey": [] } ] } } }, "components": { "securitySchemes": { "apikey": { "type": "apiKey", "name": "apikey", "in": "query" } } }, "x-readme": { "explorer-enabled": true, "proxy-enabled": true }, "_id": "64fb5d32228b460071039578" } ``` -------------------------------- ### Get PCB Version Source: https://apidocs.macrofab.com/reference/get_api-v2-pcb-pcb-id-pcb-version Retrieves full PCB details for a specified project and version. If no version is specified, the newest version is returned. ```APIDOC ## GET /websites/apidocs_macrofab ### Description Get Details about a PCB Project, Specifying which Version to Retrieve. Like getting a single PCB, this method returns full PCB details. However, you can specify a version to retrieve rather than retrieving only the newest version. ### Method GET ### Endpoint /websites/apidocs_macrofab ### Parameters #### Query Parameters - **version** (string) - Optional - The specific version of the PCB project to retrieve. If omitted, the latest version is returned. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **projectId** (string) - The unique identifier for the PCB project. - **version** (string) - The version identifier of the PCB. - **designator** (string) - The designator for the PCB. - **name** (string) - The name of the PCB. - **description** (string) - A description of the PCB. - **manufacturer** (string) - The manufacturer of the PCB. - **manufacturerPartNumber** (string) - The manufacturer's part number for the PCB. - **designStatus** (string) - The current design status of the PCB. - **creationDate** (string) - The date when the PCB design was created. - **lastModifiedDate** (string) - The date when the PCB design was last modified. #### Response Example { "projectId": "example-project-id", "version": "v1.2.0", "designator": "MAIN-PCB", "name": "Main Motherboard", "description": "The primary motherboard for the device.", "manufacturer": "Macrofab", "manufacturerPartNumber": "MF-MB-001", "designStatus": "Released", "creationDate": "2023-01-15T10:00:00Z", "lastModifiedDate": "2023-10-20T14:30:00Z" } ``` -------------------------------- ### Get User Information (Python) Source: https://apidocs.macrofab.com/reference/users-and-organizations Example of how to get user information using Python. This request requires the user's email address and an 'accept' header for JSON response. It uses the 'requests' library for making HTTP requests. ```python import requests email = 'user@example.com' # Replace with the actual email url = f'https://api.macrofab.com/user/{email}' headers = {'accept': 'application/json'} response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f'Error fetching user information: {response.status_code}') ``` -------------------------------- ### Get User Information (Ruby) Source: https://apidocs.macrofab.com/reference/users-and-organizations Example of how to get user information using Ruby. This request requires the user's email address and an 'accept' header for JSON response. It uses the 'httparty' gem for making HTTP requests. ```ruby require 'httparty' email = 'user@example.com' # Replace with the actual email response = HTTParty.get("https://api.macrofab.com/user/#{email}", headers: { 'accept' => 'application/json' }) if response.success? puts response.parsed_response else puts "Error fetching user information: #{response.code}" end ``` -------------------------------- ### Example PCB Specifications Source: https://apidocs.macrofab.com/reference/get_api-v2-pcb-pcb-id This JSON snippet details the specifications for a PCB, such as copper weight, gold fingers, impedance control, layer count, manufacturing type, silkscreen color, soldermask color, and thickness. It provides a clear overview of a PCB's physical and manufacturing attributes. ```json { "specifications": { "copper_weight": "1 ounce", "gold_fingers": "0", "impedance_control": "0", "layer_count": "2", "manufacturing": "Standard", "silkscreen_color": "any", "soldermask_color": "any", "thickness": "1.6" } } ``` -------------------------------- ### Get User Information (Node.js) Source: https://apidocs.macrofab.com/reference/users-and-organizations Example of how to get user information using Node.js. This request requires the user's email address and an 'accept' header for JSON response. It uses the 'axios' library for making HTTP requests. ```javascript const axios = require('axios'); const email = 'user@example.com'; // Replace with the actual email axios.get(`https://api.macrofab.com/user/${email}`, { headers: { 'accept': 'application/json' } }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error fetching user information:', error); }); ``` -------------------------------- ### POST /api/v2/pcb Source: https://apidocs.macrofab.com/reference/post_api-v2-pcb Creates a new PCB project by accepting a JSON object containing the project's name and a short description. The response includes the full object definition of the created PCB. ```APIDOC ## POST /api/v2/pcb ### Description Create a new PCB Project. You can specify the name of the PCB project and the short description of the project using a single JSON object passed as the body of the request. Responds with the full object definition of the PCB upon successful creation. ### Method POST ### Endpoint /api/v2/pcb ### Parameters #### Request Body - **pcb** (object) - Required - The PCB object containing name and short description. - **name** (string) - Required - The new name of the PCB. - **short** (string) - Required - The new short description of the PCB. ### Request Example ```json { "pcb": { "name": "The new name of the PCB", "short": "The new short description of the PCB" } } ``` ### Response #### Success Response (200) - **pcb_id** (string) - The unique identifier for the created PCB. - **uri** (string) - The URI to access the created PCB. #### Response Example ```json { "pcb": { "pcb_id": "kpqt9m", "uri": "/pcb/kpqt9m" } } ``` ``` -------------------------------- ### Get Order List using PHP Source: https://apidocs.macrofab.com/reference/orders-1 This PHP example demonstrates how to retrieve a list of orders from the Macrofab API using cURL. It sets the appropriate headers and processes the JSON response. ```php ``` -------------------------------- ### Get PCB Layers - OpenAPI Definition Source: https://apidocs.macrofab.com/reference/get_api-v2-pcb-pcb-id-pcb-version-layers This OpenAPI 3.0.1 definition describes the MacroFab API, specifically the GET endpoint for retrieving PCB layers. It includes details on request parameters, response structure, and example data for PCB layers. ```json { "openapi": "3.0.1", "info": { "title": "MacroFab API", "description": "MacroFab API", "version": "1.0.0" }, "servers": [ { "url": "https://api.macrofab.com/" } ], "paths": { "/api/v2/pcb/{pcb_id}/{pcb_version}/layers": { "get": { "tags": [ "PCB" ], "summary": "Get PCB Layers", "description": "Get List of PCB Version Project Files\n\nReturns a list of all files currently uploaded and recognized for the specified\nPCB project version.\n", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "example": { "pcb_layers": [ { "files": [ { "basename": "pcbtop.svg", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcbtop.svg", "layer": "all_top", "modified": "Mon, 24 Sep 2018 21:55:26 GMT", "preview": { "basename": "pcbtop.svg", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcbtop.svg", "layer": "all_top", "modified": "Mon, 24 Sep 2018 21:55:26 GMT", "size": 275571, "state": "processed", "type": "svg" }, "size": 275571, "state": "processed", "thumbnail": { "basename": "pcbtop.png", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcbtop.png", "layer": "all_top", "modified": "Mon, 24 Sep 2018 21:55:27 GMT", "size": 98021, "state": "processed", "type": "png_image" }, "type": "svg" } ], "id": "all_top", "name": "Top Preview", "side": "top" }, { "files": [ { "basename": "pcb.bor", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcb.bor", "layer": "board_outline", "modified": "Mon, 24 Sep 2018 21:55:23 GMT", "preview": { "basename": "pcb.bor.svg", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcb.bor.svg", "layer": "board_outline", "modified": "Mon, 24 Sep 2018 21:55:24 GMT", "size": 434, "state": "processed", "type": "svg" }, "size": 100, "state": "processed", "thumbnail": { "basename": "pcb.bor.png", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcb.bor.png", "layer": "board_outline", "modified": "Mon, 24 Sep 2018 21:55:26 GMT", "size": 1191, "state": "processed", "type": "png_image" }, "type": "gerber" } ], "id": "board_outline", "name": "Board Outline", "side": "both" }, { "files": [ { "basename": "pcb.gtp", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcb.gtp", "layer": "top_paste", "modified": "Mon, 24 Sep 2018 21:55:23 GMT", "preview": { "basename": "pcb.gtp.svg", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcb.gtp.svg", "layer": "top_paste", "modified": "Mon, 24 Sep 2018 21:55:23 GMT", "size": 8506, "state": "processed", "type": "svg" }, "size": 2504, "state": "processed", "thumbnail": { "basename": "pcb.gtp.png", "key": "mv8ptg/pcbs/k10hxm/1/processed/pcb.gtp.png", "layer": "top_paste", "modified": "Mon, 24 Sep 2018 21:55:25 GMT", "size": 1150, "state": "processed", "type": "png_image" }, "type": "gerber" } ], "id": "top_paste", "name": "Top Paste", "side": "top" } ] } } } } } } } } } } ``` -------------------------------- ### List PCB Projects Source: https://apidocs.macrofab.com/reference/get_api-v2-pcbs Retrieves a list of all PCB Projects associated with your account. ```APIDOC ## GET /api/v2/pcbs ### Description Retrieve a list of all PCB Projects. ### Method GET ### Endpoint /api/v2/pcbs ### Parameters #### Query Parameters - **apikey** (string) - Required - Your API key for authentication. ### Request Example ``` GET /api/v2/pcbs?apikey=YOUR_API_KEY ``` ### Response #### Success Response (200) - **pcb_list** (array) - A list of PCB project objects. - **created** (string) - The creation timestamp of the PCB project. - **description** (string) - A description of the PCB project. - **name** (string) - The name of the PCB project. - **pcb_id** (string) - The unique identifier for the PCB project. - **preview** (string) - Indicates if a preview is available. - **public** (string) - Indicates if the PCB project is public. - **short** (string) - A short description of the PCB project. - **uri** (string) - The URI to access the specific PCB project. - **user_id** (string) - The ID of the user who owns the PCB project. - **version** (string) - The version of the PCB project. #### Response Example ```json { "pcb_list": [ { "created": "2018-07-09 17:04:50", "description": null, "name": "New PCB", "pcb_id": "k10hxm", "preview": "1", "public": "0", "short": "A short description.", "uri": "/pcb/k10hxm", "user_id": "1", "version": "1" } ] } ``` ``` -------------------------------- ### Get PCB Bill of Materials (BOM) - OpenAPI Definition Source: https://apidocs.macrofab.com/reference/get_api-v3-pcb-pcb-id-pcb-version-bom This OpenAPI 3.0.1 definition describes the MacroFab API, specifically the endpoint for retrieving the Bill of Materials (BOM) for a given PCB ID and version. It details the request parameters, response structure, and provides an example of the BOM data, including component details like 'populate', 'selected_part', and 'selected_mpn'. ```json { "openapi": "3.0.1", "info": { "title": "MacroFab API", "description": "MacroFab API", "version": "1.0.0" }, "servers": [ { "url": "https://api.macrofab.com/" } ], "paths": { "/api/v3/pcb/{pcb_id}/{pcb_version}/bom": { "get": { "tags": [ "PCB" ], "summary": "Get BOM", "description": "Retrieve the PCB Bill of Materials for a Specific Version.\nThe _bom_ key points to an array of bill of materials entries, one for each component listed on the board. Each element is an object that describes that component. While several of the object keys are obvious in their meaning, some require more detail:\n\n**populate**\nThe populate key indicates whether you have specified that the particular instance of that component be populated on the board. By default, it is set to true, unless you have unchecked the populate option for this component in the Bill of Materials view for the PCB in the user interface. This key having a value of true does not, however, ensure the part's population in assembly. The component must also have either a matched, selected, or house part associated with it.\n\n**selected_part**, **selected_mpn**\nA single MPN can be manufactured by a number of vendors, so we assign every part a unique ID. The ID for an MPN can be discovered through parts searches.\nFor convenience, we return the MPN with the results.\n", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "example": { "bom": { "approved_vendors": [], "created": "Mon, 09 Jul 2018 16:48:09 GMT", "name": "Automatically generated BOM from XYRS for PCB 1", "notes": null, "organizations": [ "mr2rt2" ], "parts": [ { "allow_substitute": true, "alternate_parts": [], "created": "Mon, 09 Jul 2018 16:48:09 GMT", "description": null, "device": ".1uF", "group_key": null, "mpn": null, "notes": null, "origin": "turnkey", "package": "0603", "part": "C10", "populate": true, "record_num": 26, "selected_mpn": null, "selected_part": "MF-CAP-0603-0.1uF", "updated": "Mon, 09 Jul 2018 17:28:11 GMT", "uri": "/api/v3/bom/b72eafe88428444b980a09d2def93216/1/part/C10", "value": ".1uF" }, { "allow_substitute": true, "alternate_parts": [], "created": "Mon, 09 Jul 2018 16:48:09 GMT", "description": null, "device": ".1uF", "group_key": null, "mpn": null, "notes": null, "origin": "turnkey", "package": "0603", "part": "C11", "populate": true, "record_num": 27, "selected_mpn": null, "selected_part": "MF-CAP-0603-0.1uF", "updated": "Mon, 09 Jul 2018 17:28:11 GMT", "uri": "/api/v3/bom/b72eafe88428444b980a09d2def93216/1/part/C11", "value": ".1uF" }, { "allow_substitute": true, "alternate_parts": [], "created": "Mon, 09 Jul 2018 16:48:09 GMT", "description": null, "device": "NCP1117LPST33T3G", "group_key": null, "mpn": null, "notes": null, "origin": "turnkey", "package": "SOT-223-3", "part": "U6", "populate": false, "record_num": 44, "selected_mpn": "NCP1117LPST33T3G", "selected_part": "c21b4122-c383-561e-8e80-d9cfa635e28a", "updated": "Mon, 09 Jul 2018 17:28:47 GMT", "uri": "/api/v3/bom/b72eafe88428444b980a09d2def93216/1/part/U6" } ] } } } } } } } } } } } ``` -------------------------------- ### Get PCB Project Details Source: https://apidocs.macrofab.com/reference/get_api-v2-pcb-pcb-id Retrieves details about a PCB project, defaulting to the newest version if no specific version is provided. The response includes access URIs for all available versions of the PCB project. ```APIDOC ## GET /websites/apidocs_macrofab ### Description Get Details about a PCB Project, Using the Newest Version. The full details about the PCB project will be returned when accessing this endpoint. Since there can be multiple versions of a PCB, retrieving only with pcb_id and without the pcb_version will return details about the newest version by default. Included in the response will be details and access URIs for each specific version of the PCB project available. ### Method GET ### Endpoint /websites/apidocs_macrofab ### Parameters #### Query Parameters - **pcb_id** (string) - Required - The unique identifier for the PCB project. - **pcb_version** (string) - Optional - The specific version of the PCB project to retrieve details for. If omitted, the newest version is returned. ### Response #### Success Response (200) - **project_name** (string) - The name of the PCB project. - **latest_version** (string) - The identifier for the newest version of the PCB project. - **versions** (array) - A list of available PCB project versions. - **version_id** (string) - The identifier for a specific version. - **version_uri** (string) - The URI to access the details of this specific version. #### Response Example ```json { "project_name": "MyAwesomePCB", "latest_version": "v1.2.0", "versions": [ { "version_id": "v1.0.0", "version_uri": "/websites/apidocs_macrofab/v1.0.0" }, { "version_id": "v1.1.0", "version_uri": "/websites/apidocs_macrofab/v1.1.0" }, { "version_id": "v1.2.0", "version_uri": "/websites/apidocs_macrofab/v1.2.0" } ] } ``` ``` -------------------------------- ### Get Order List using Python Source: https://apidocs.macrofab.com/reference/orders-1 This Python snippet shows how to make a GET request to the Macrofab API to get a list of orders. It uses the 'requests' library and handles the JSON response. ```python import requests url = 'https://api.macrofab.com/api/v2/orders' headers = { 'accept': 'application/json' } try: response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes orders = response.json() print(orders) except requests.exceptions.RequestException as e: print(f'Error fetching orders: {e}') ``` -------------------------------- ### Project and Order Details Source: https://apidocs.macrofab.com/reference/get_api-v2-order-order-id This section details the structure of project and order information, including part details, status, and associated metadata. ```APIDOC ## Project and Order Schema Details ### Description Provides a detailed schema for project and order information, including nested structures for parts and events. ### Method N/A (Schema definition) ### Endpoint N/A (Schema definition) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body **Schema for Project/Order Object:** - **consignment_expiry** (string, nullable) - Expiry date for consignment. - **created** (string) - Timestamp of creation. - **deal_id** (string) - Identifier for the deal. - **down_payment** (string) - Down payment amount. - **due** (string, date) - Due date. - **email** (string) - Email address. - **events** (array) - List of events associated with the order. - **items** (object) - **created** (string) - Timestamp of event creation. - **event** (string) - Type of event. - **event_details** (string) - Details of the event. - **facility** (string) - Facility identifier. - **fileManifest** (object) - File manifest details. - **files** (object) - **Hybrid.Bottom.16.grb** (object) - **metadata** (object) - Metadata for the file. - **material_type** (string) - Type of material. - **name** (string, nullable) - Name of the project or order. - **order_id** (string) - Identifier for the order. - **organization_id** (string) - Identifier for the organization. - **parts** (array) - List of parts in the order. - **items** (object) - **component_count** (integer) - Number of components. - **component_type** (string) - Type of component. - **components_received** (integer) - Number of components received. - **deprecated_count** (integer) - Number of deprecated components. - **deprecating_eco_id** (string, nullable) - ECO ID for deprecation. - **id** (string, nullable) - Part identifier. - **mount_type** (integer) - Mount type. - **order_id** (string) - Order identifier for the part. - **organization_id** (string) - Organization identifier for the part. - **overage** (integer) - Overage quantity. - **part_num** (string) - Part number. - **pin_count** (integer) - Number of pins. - **plan_by_date** (string, nullable) - Planned date. - **unit_count** (integer) - Unit count for the part. - **status** (string) - Status of the order. - **tracking_number** (string, nullable) - Tracking number for shipment. - **user_email** (string) - Email of the user who placed the order. - **user_id** (string) - User identifier. - **user_name** (string) - Name of the user. ### Request Example ```json { "consignment_expiry": null, "created": "2023-10-27T10:00:00Z", "deal_id": "deal-123", "down_payment": "100.00", "due": "2023-11-30", "email": "user@example.com", "events": [ { "created": "2023-10-27T10:05:00Z", "event": "Order Placed", "event_details": "Order successfully placed." } ], "facility": "facility-abc", "fileManifest": { "files": { "Hybrid.Bottom.16.grb": { "metadata": {} } } }, "material_type": "PCB", "name": "My Project Board", "order_id": "order-xyz", "organization_id": "org-789", "parts": [ { "component_count": 50, "component_type": "Resistor", "components_received": 45, "deprecated_count": 0, "deprecating_eco_id": null, "id": "part-001", "mount_type": 1, "order_id": "order-xyz", "organization_id": "org-789", "overage": 5, "part_num": "RES-10K-0603", "pin_count": 2, "plan_by_date": null, "unit_count": 100 } ], "status": "Processing", "tracking_number": null, "user_email": "user@example.com", "user_id": "user-456", "user_name": "John Doe" } ``` ### Response #### Success Response (200) - **Schema**: Returns the detailed project/order object as described above. #### Response Example (See Request Example, as the success response mirrors the structure of the request body for a complete order/project object.) ```