API Documentation

YouPaste API (versión 0.2) uses JSON with HTTP POST requests.

API URL -> http://youpaste.co/api
(Content-Type: application/json)

The following is the documentation relating to the protection system MegaCrypter:

Info-request (for retrieving some file information):

{
  "m": "info",
  "link": "MC_LINK"
}

Info-response:

{
  "name": "FILE_NAME",
  "path": false OR "PATH" OR "CRYPTED_FILE_PATH"
  "size": FILE_SIZE,
  "key": "FILE_KEY",
  "extra": "EXTRA_INFO",
  "expire": false OR "EXPIRE_TIMESTAMP#NOEXPIRE_TOKEN",
  "pass": false OR "ITER_LOG2#KEY_CHECK_HMAC#SALT#IV"
}

*About password protected files: File name, file key, and extra-info will be returned crypted using AES CBC (PKCS7) with 256 bits key derivated from pass.

Follow this algorithm to decrypt crypted fields:

REPEAT

    password := read_password()

    info_key := hmac := hmac_sha256(password, base64_dec(SALT))

    FOR i=2 : 1 : pow(2, ITER_LOG2)

        hmac := hmac_sha256(password, hmac)

        info_key := info_key XOR hmac

    END

UNTIL hmac_sha256(base64_dec(IV), info_key) = base64_dec(KEY_CHECK_HMAC)

crypted_field := aes_cbc_dec(base64_dec(CRYPTED_FIELD), info_key, base64_dec(IV))
    

Note: iteration count is -> pow(2, 14) = 16384

Dl-request (for getting a temporary url to the (crypted) file):

{
  "m": "dl",
  "link": "MC_LINK",
  *"ssl": true OR false
  *"noexpire": "NOEXPIRE_TOKEN"
}

*Optional params: 1) Default is false (better performance in slow machines)
2) If link has expiration time you can use NOEXPIRE_TOKEN (cached from a previous "info-request") to bypass it and get the download url.

Dl-response:

{
  "url": "MEGA_TEMP_URL" OR "CRYPTED_MEGA_TEMP_URL"
  "pass": false OR "IV"
}

Note: use the same algorithm described above to decrypt temp url (if password protected)

Error-response (because shit happens...):

{
  "error": ERROR_CODE
}

Error codes:

MC_EMETHOD(1)
MC_EREQ(2)
MC_INTERNAL_ERROR(21)
MC_LINK_ERROR(22)
MC_BLACKLISTED_LINK(23)
MC_EXPIRED_LINK(24)
MEGA_EINTERNAL(-1)
MEGA_EARGS(-2)
MEGA_EAGAIN(-3)
MEGA_ERATELIMIT(-4)
MEGA_EFAILED(-5)
MEGA_ETOOMANY(-6)
MEGA_ERANGE(-7)
MEGA_EEXPIRED(-8)
MEGA_ENOENT(-9)
MEGA_ECIRCULAR(-10)
MEGA_EACCESS(-11)
MEGA_EEXIST(-12)
MEGA_EINCOMPLETE(-13)
MEGA_EKEY(-14)
MEGA_ESID(-15)
MEGA_EBLOCKED(-16)
MEGA_EOVERQUOTA(-17)
MEGA_ETEMPUNAVAIL(-18)
MEGA_ETOOMANYCONNECTIONS(-19)
MEGA_EWRITE(-20)
MEGA_EREAD(-21)
MEGA_EAPPKEY(-22)
MEGA_EDLURL(-101)