Navigation ↓

Example Queries

Here are a few examples of actually consuming the Milk API in Javascript with axios. If you are using something else, hopefully these examples will be easy enough to translate into your language of choice.

All Content

import axios from "axios";

const appUUID = "PN4BZCE3"
const params = {
    access_token: "umQLjqnWwPQjQH0uSy8QhKKZfobdSr4NIjV"
};

const req = await axios.post(
    "https://milk.jwb.cloud/api/cdn/" + appUUID,
    params    // Only parameter is the access token
);

if (req.data.error) {
    console.log(req.data.error);
    return null;
} else {
    return req.data.contents
}

Specific Title

import axios from "axios";

const appUUID = "PN4BZCE3"
const params = {
    access_token: "umQLjqnWwPQjQH0uSy8QhKKZfobdSr4NIjV",
    content_type: "article",                 // Content Type must be specified to query fields
    fields: {
        "title": "Wandering the Pastures"    // Only content with this title will be returned
    }
};

const req = await axios.post(
    "https://milk.jwb.cloud/api/cdn/" + appUUID,
    params
);

if (req.data.error) {
    console.log(req.data.error);
    return null;
} else {
    return req.data.contents
}

Containing All Tags

import axios from "axios";

const appUUID = "PN4BZCE3"
const params = {
    access_token: "umQLjqnWwPQjQH0uSy8QhKKZfobdSr4NIjV",
    content_type: "article",
    fields: {
        "tags": ["Agriculture", "Food"]    // Content with both Agriculture and Food tags
    }
};

const req = await axios.post(
    "https://milk.jwb.cloud/api/cdn/" + appUUID,
    params
);

if (req.data.error) {
    console.log(req.data.error);
    return null;
} else {
    return req.data.contents
}

Containing Any Tags

Same code as above with this line change:

"tags[any]": ["Agriculture", "Food"]

"any" can be replaced will "all" for the default effect

URL parameters

If you'd prefer to use URL parameters rather than a JSON body, here's a simple example. Without a JSON body, you can you a GET request rather than a POST.

import axios from "axios";

const req = await axios.get(
    `https://milk.jwb.cloud/api/cdn/PN4BZCE3?access_token=umQLjqnWwPQjQH0uSy8QhKKZfobdSr4NIjV
    &content_type=article
    &fields.title=Wandering the Pastures`
);

if (req.data.error) {
    console.log(req.data.error);
    return null;
} else {
    return req.data.contents
}