Skip to content

API Usage Examples

Please find below a few examples of integrations with the MDM API

Uploading your APK assets into the MDM

With scripts

import requests

url = "https://my.famoco.com/api/organizations/<your_org_id>/applications/"
apk_path = "app-release.apk"

with open(apk_path, "rb") as f:
    files = {
        "apk": (apk_path, f, "application/vnd.android.package-archive"),
    }
    headers = {"Authorization": "Bearer YOUR_TOKEN"}
    resp = requests.post(url, files=files, headers=headers)

resp.raise_for_status()
print(resp.status_code, resp.text)
curl -sf -X POST https://my.famoco.com/api/organizations/<your_org_id>/applications/ \
-H "Authorization: Bearer ${YOUR_TOKEN}" \
-F "apk=@app-release.apk;type=application/vnd.android.package-archive"

or on a CI/CD pipeline

httpRequest(
    url: 'https://my.famoco.com/api/organizations/<your_org_id>/applications/',
    httpMode: 'POST',
    customHeaders: [[name: 'Authorization', value: "Bearer ${env.TOKEN}"]],
    uploadFile: 'app-release.apk',
    multipartName: 'apk',
    wrapAsMultipart: true
)
name: Upload APK
on:
workflow_dispatch:

jobs:
upload:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    # If the APK is a build artifact from an earlier job:
    - uses: actions/download-artifact@v4
        with:
        name: app-release

    - name: Upload APK to API
        env:
        API_TOKEN: ${{ secrets.API_TOKEN }}
        run: |
        curl -sf -X POST https://my.famoco.com/api/organizations/<your_org_id>/applications/ \
            -H "Authorization: Bearer $API_TOKEN" \
            -F "apk=@app-release.apk;type=application/vnd.android.package-archive"
stages:
- build
- upload

build_apk:
stage: build
script:
    - ./gradlew assembleRelease
artifacts:
    paths:
    - app/build/outputs/apk/release/app-release.apk
    expire_in: 1 day

upload_apk:
stage: upload
needs: ["build_apk"]
variables:
    APK_PATH: "app/build/outputs/apk/release/app-release.apk"
script:
    - |
    curl -sf -X POST "https://my.famoco.com/api/organizations/<your_org_id>/applications/" \
        -H "Authorization: Bearer ${API_TOKEN}" \
        -F "apk=@${APK_PATH};type=application/vnd.android.package-archive"

Exporting data

Any MDM data which is exportable through the MDM front-end is also exportable through the API.

GET https://my.famoco.com/api/organizations/<your_org_id>/<resource>/export/

By default, the data is returned in the JSON format. You may also retrieve a CSV file by adding the following header: Accept: text/csv.

We highly recommend you to select which fields you require and explicitly name them in your API call, in order reduce the load on our services. For example:

GET (...)/devices/export/?fields=famoco_id,fleet,last_sync_date