NAV
python shell javascript

Intro

Instantly make your files searchable with the mixpeek API.

We currently support a native Python module installable via pip. These docs however will be for the APIs directly.

Authenticate

To authorize, use this code:

import requests

headers = {
  'Authorization': 'API_KEY'
}

response = requests.request("GET", 'https://api.mixpeek.com/', headers=headers)
curl --request GET 'https://api.mixpeek.com/' --header 'Authorization: API_KEY'
fetch('https://https://api.mixpeek.com/', {
  headers: new Headers({
    'Authorization': 'API_KEY'
  })
})

mixpeek uses API keys to allow access to the API. You can register a mixpeek API key using this form.

mixpeek expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: API_KEY

Make sure to replace API_KEY with your API key.

Upload

Replace FILE_NAME with an absolute path of your local file:

import requests

url = "https://api.mixpeek.com/upload"
files=[
  ('file',('FILE_NAME.png',open('FILE_NAME.png','rb'),'image/png'))
]
response = requests.request("POST", url, files=files)

curl --location --request POST 'https://api.mixpeek.com/upload' \
--form 'file=@"FILE_NAME.png"'

var formdata = new FormData();
formdata.append("file", fileInput.files[0], "FILE_NAME.png");

var requestOptions = {
  method: 'POST',
  body: formdata
};

fetch("https://api.mixpeek.com/upload", requestOptions)
  .then(response => response.text());

The above commands return a JSON structured like this:

{
    "code": 200,
    "endpoint": "/upload",
    "ok": true,
    "response": {
        "_id": "REDACTED",
        "api_key": "API_KEY",
        "document_str": "If you have a demo, what's the url? Demo can be anything that show...",
        "file_url": null,
        "metadata": {
            "date_inserted": "2021-12-29 00:46:44.507141",
            "filename": "FILE_NAME.png"
        }
    },
    "timestamp": 1640738804.5198598
}

This securely sends your file to our server so its' text can be extracted and placed in a search engine.

HTTP Request

POST https://api.mixpeek.com/upload

Query Parameters

Name Necessity Description
user_id Optional Used to run isolated queries against individual user's files.
file_url Optional So that you can reference the file's path in your software (NOTE: we do not store the file, you need to reference it in your code).

File

Name Necessity Description
file Required Path of your local file to be sent to the server.

Search

This searches your files for the text provided.

Replace SEARCH_QUERY with what you'd like to search.

import requests
import json

url = "https://api.mixpeek.com/search?q=SEARCH_QUERY"

payload = json.dumps({
  "clauses": [
    {
      "operator": "and",
      "query": "lorem"
    },
    {
      "operator": "and not",
      "query": "ipsum"
    },
    {
      "operator": "or",
      "query": "dolor"
    }
  ]
})

response = requests.request("GET", url, data=payload)

print(response.text)

curl --location --request GET 'https://api.mixpeek.com/search?q=SEARCH_QUERY' \
--data-raw '{"clauses":        [
            {
                "operator":"and",
                "query":"lorem"
            },
            {
                "operator":"and not",
                "query":"ipsum"
            },
            {
                "operator":"or",
                "query":"dolor"
            }
        ]}'

var raw = JSON.stringify({
  "clauses": [
    {
      "operator": "and",
      "query": "lorem"
    },
    {
      "operator": "and not",
      "query": "ipsum"
    },
    {
      "operator": "or",
      "query": "dolor"
    }
  ]
});

var requestOptions = {
  method: 'GET',
  body: raw,
  redirect: 'follow'
};

fetch("https://api.mixpeek.com/search?q=SEARCH_QUERY", requestOptions)
  .then(response => response.text());

The above commands return a JSON structured like this:

[
    {
        "_id": "REDACTED",
        "api_key": "API_KEY",
        "file_url": null,
        "highlights": [
            {
                "path": "document_str",
                "score": 0.8759502172470093,
                "texts": [
                    {
                        "type": "text",
                        "value": "Australian Shepherd\n\nDate of Service: 2 Years 8 Months\n\nPrescription\nExpiration Date:\n\nWeight: 41.75\n\nSex: Female\n\n℞  Heartgard Plus Green 26-50 lbs ("
                    },
                    {
                        "type": "hit",
                        "value": "Ivermectin"
                    },
                    {
                        "type": "text",
                        "value": " 135 mcg/Pyrantel 114 mg)\n\nInstructions: Give one chewable tablet by mouth once monthly for protection against heartworms, and the treatment and\ncontrol of roundworms, and hookworms."
                    }
                ]
            }
        ],
        "metadata": {
            "date_inserted": "2021-12-28 19:45:38.469000",
            "file": {
                "Content-Type": "application/pdf",
                "Creation-Date": "2021-09-14T20:06:35Z"
            },
            "filename": "prescription.pdf"
        },
        "score": 1.4865798950195312
    }
]

HTTP Request

GET https://api.mixpeek.com/search

Query Parameters

Name Necessity Description
q Required Your search query
user_id Optional Filter, used to run isolated queries against individual user's files.

Request Body

Name Necessity Description
clauses Optional Array of objects for clauses to the search engine. Each object must contain keys: operator (OR, AND, AND NOT) and query.

Errors

The mixpeek API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
404 Not Found -- The specified API could not be found.
405 Method Not Allowed -- You tried to access a API with an invalid method.
429 Too Many Requests -- You're requesting too many APIs! Slow down!
500 Internal Server Error -- We had a problem with our server. Please reach out to us.