EarlGrey REST API
BrowserStack supports the use of REST API to access information about your tests via the command-line interface.
App Upload
Upload App Directory
An API to upload the app directory for the App and test you want to execute on the BrowserStack servers
curl -u "USERNAME:ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/earlgrey/app-dir" -F "file=@/path/to/app/file/appDir.zip" -F 'data={"custom_id": "MyTest"}'
Upload zip from a Public Location
If you do not have your zip file on the local machine from where you are running the test and it is hosted on a different location, you can upload it to the BrowserStack servers from any public hosted location. You can achieve that by just providing the zip public url in the API call to upload an zip. The url should be accessible over the internet so that BrowserStack can directly upload it from that location. Use the below API call to upload zip from a publicly accessible location.
curl -u "USERNAME:ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/earlgrey/app-dir" -F "data={\"url\": \"https://www.browserstack.com/app-automate/sample-apps/ios/BStack-EarlGrey-SampleApp.zip\"}"
Delete App Directory
An API to DELETE an uploaded App Directory
curl -u "USERNAME:ACCESS_KEY" -X DELETE "https://api-cloud.browserstack.com/app-automate/earlgrey/app-dirs/:hashed_id"
Get recent Uploads
An API to retrieve details of your recently uploaded test suites
curl -u "USERNAME:ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/earlgrey/app-dirs
Get App Directory info
An API to get detail information about the uploaded test suite
curl -u "USERNAME:ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/earlgrey/app-dirs/:hashed_id
Builds
Build Summary / Test status
An API to get the status of your test execution or fetch the summary of your build
curl -u "USERNAME:ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/earlgrey/builds/:build_id
Sessions
Session Details
An API to get the details of your test sessions. Each session is the execution of your test suite on individual devices.
curl -u "USERNAME:ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/earlgrey/builds/:build_id/sessions/:session_id
Retrieving App Automate network logs
Logs are available to you in HAR (HTTP Archive) format, and these can be retrieved using REST API.
curl -u "USERNAME:ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/earlgrey/builds/:build_id/sessions/tests/:test_id/networklogs
Media Upload
Upload Media
An API to upload media files you want to use in your tests running on the BrowserStack servers
curl -u "USERNAME:ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload-media" -F "file=@/path/to/media/file/mediaFile.jpg" -F 'data={"custom_id": "MyMedia"}'
Get recent uploads
An API to retrieve details about your recent Media File uploads. The response will not include the deleted Media Files
curl -u "USERNAME:ACCESS_KEY" -X GET "https://api-cloud.browserstack.com/app-automate/recent_media_files"
Get recent uploads for custom id
An API to retrieve details about your recent Media File uploads under a specific custom id. The response will not include the deleted Media Files
curl -u "USERNAME:ACCESS_KEY" -X GET "https://api-cloud.browserstack.com/app-automate/recent_media_files/<custom_id>"
Get recent uploads for entire group
An API to retrieve details about your recent Media File uploads for the entire group. The response will not include the deleted Media Files
curl -u "USERNAME:ACCESS_KEY" -X GET "https://api-cloud.browserstack.com/app-automate/recent_group_media"
Delete Media File
An API to DELETE an uploaded Media File
curl -u "USERNAME:ACCESS_KEY" -X DELETE "https://api-cloud.browserstack.com/app-automate/custom_media/delete/<MediaId>"