{"id":13414091,"url":"https://github.com/bitfield/uptimerobot","last_synced_at":"2025-04-15T11:32:06.204Z","repository":{"id":44967703,"uuid":"135279732","full_name":"bitfield/uptimerobot","owner":"bitfield","description":"Client library for UptimeRobot v2 API","archived":false,"fork":false,"pushed_at":"2023-04-22T13:31:56.000Z","size":175,"stargazers_count":57,"open_issues_count":13,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T21:02:26.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfield.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"bitfield"}},"created_at":"2018-05-29T10:27:19.000Z","updated_at":"2025-01-02T22:34:56.000Z","dependencies_parsed_at":"2024-06-18T21:18:05.818Z","dependency_job_id":"7ff0bef9-0990-40c2-a5fa-fc20bf3ab22a","html_url":"https://github.com/bitfield/uptimerobot","commit_stats":{"total_commits":117,"total_committers":7,"mean_commits":"16.714285714285715","dds":0.0854700854700855,"last_synced_commit":"3785594ec6d3fc96104a83b416b12bb429f2a23d"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfield%2Fuptimerobot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfield%2Fuptimerobot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfield%2Fuptimerobot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfield%2Fuptimerobot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfield","download_url":"https://codeload.github.com/bitfield/uptimerobot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249061091,"owners_count":21206450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:57.436Z","updated_at":"2025-04-15T11:32:05.959Z","avatar_url":"https://github.com/bitfield.png","language":"Go","funding_links":["https://github.com/sponsors/bitfield"],"categories":["Third-party APIs","第三方api","Go","第三方API","Utility","第三方API`第三方API 汇总`"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous","HTTP Clients","查询语","Fail injection","交流"],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/bitfield/uptimerobot.svg)](https://pkg.go.dev/github.com/bitfield/uptimerobot)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bitfield/uptimerobot)](https://goreportcard.com/report/github.com/bitfield/uptimerobot)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go)\n![Tests](https://github.com/bitfield/uptimerobot/actions/workflows/test.yml/badge.svg)\n\n# uptimerobot\n\n`uptimerobot` is a Go library and command-line client for the [Uptime Robot](https://uptimerobot.com/) website monitoring service. It allows you to search for existing monitors, delete monitors, create new monitors, and also inspect your account details and alert contacts.\n\n## Installing the command-line client\n\nTo install the client binary, run:\n\n```\ngo get -u github.com/bitfield/uptimerobot\n```\n\n## Running the command-line client in Docker\n\nTo use the client in a Docker container, run:\n\n```\ndocker container run bitfield/uptimerobot\n```\n\n## Using the command-line client\n\nTo see help on using the client, run:\n\n```\nuptimerobot -h\n```\n\n## Setting your API key\n\nTo use the client with your Uptime Robot account, you will need the Main API Key for the account. Go to the [Uptime Robot Settings page](https://uptimerobot.com/dashboard.php#mySettings) and click 'Show/hide it' under the 'Main API Key' section.\n\nThere are three ways to pass your API key to the client: in a config file, in an environment variable, or on the command line.\n\n### In a config file\n\nThe `uptimerobot` client will read a config file named `.uptimerobot.yaml` (or `.uptimerobot.json`, or any other extension that Viper supports) in your home directory, or in the current directory.\n\nFor example, you can put your API key in the file `$HOME/.uptimerobot.yaml`, and `uptimerobot` will find and read it automatically (replace `XXX` with your own API key):\n\n```yaml\napiKey: XXX\n```\n\n### In an environment variable\n\n`uptimerobot` will look for the API key in an environment variable named UPTIMEROBOT_API_KEY:\n\n```\nexport UPTIMEROBOT_API_KEY=XXX\nuptimerobot ...\n```\n\n(For historical reasons, the variable can also be named `UPTIMEROBOT_APIKEY`.)\n\n### On the command line\n\nYou can also pass your API key to the `uptimerobot` client using the `--apiKey` flag like this:\n\n```\nuptimerobot --apiKey XXX ...\n```\n\n## Testing your configuration\n\nTo test that your API key is correct and `uptimerobot` is reading it properly, run:\n\n```\nuptimerobot account\n```\n\nYou should see your account details listed:\n\n```\nEmail: j.random@example.com\nMonitor limit: 300\nMonitor interval: 1\nUp monitors: 208\nDown monitors: 2\nPaused monitors: 0\n```\n\nIf you get an error message, double-check you have the correct API key:\n\n```\n2018/07/12 16:04:26 API error: {\n \"message\": \"api_key not found.\",\n \"parameter_name\": \"api_key\",\n \"passed_value\": \"XXX\",\n \"type\": \"invalid_parameter\"\n}\n```\n\n## Listing contacts\n\nThe `uptimerobot contacts` command will list your configured alert contacts by ID number:\n\n```\nuptimerobot contacts\nID: 0102759\nName: Jay Random\nType: 2\nStatus: 2\nValue: j.random@example.com\n\nID: 2053888\nName: Slack\nType: 11\nStatus: 2\nValue: https://hooks.slack.com/services/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\n```\n\nThis will be useful when you create a new monitor, because you can add the contact IDs which should be alerted when the check fails (see 'Creating a new monitor' below).\n\n## Listing or searching for monitors\n\nUse `uptimerobot search` to list all monitors whose 'friendly name' or check URL match a certain string:\n\n```\nuptimerobot search www.example.com\nID: 780689017\nName: Example.com website\nURL: https://www.example.com/\nStatus: Up\nType: HTTP\n```\n\n(Use `uptimerobot monitors` to list all existing monitors.)\n\nIf there are no monitors found matching your search, the exit status of the command will be 1. Otherwise it will be 0. (If you're checking whether a monitor already exists before creating it, try the `ensure` command instead.)\n\n## Deleting monitors\n\nNote the ID number of the monitor you want to delete, and run `uptimerobot delete`:\n\n```\nuptimerobot delete 780689017\nMonitor ID 780689017 deleted\n```\n\n## Pausing or starting monitors\n\nNote the ID number of the monitor you want to pause, and run `uptimerobot pause`:\n\n```\nuptimerobot pause 780689017\nMonitor ID 780689017 paused\n```\n\nTo resume a paused monitor, run `uptimerobot start` with the monitor ID:\n\n```\nuptimerobot start 780689017\nMonitor ID 780689017 started\n```\n\n## Creating a new monitor\n\nRun `uptimerobot new URL NAME` to create a new monitor:\n\n```\nuptimerobot new https://www.example.com/ \"Example.com website\"\nNew monitor created with ID 780689018\n```\n\nTo create a new monitor with alert contacts configured, use the `-c` flag followed by a comma-separated list of contact IDs, with no spaces:\n\n```\nuptimerobot new -c 0102759,2053888 https://www.example.com/ \"Example.com website\"\nNew monitor created with ID 780689019\n```\n\n## Ensuring a monitor exists\n\nSometimes you want to create a new monitor only if a monitor doesn't already exist for the same URL. This is especially useful in automation.\n\nTo do this, run `uptimerobot ensure URL NAME`:\n\n```\nuptimerobot ensure https://www.example.com/ \"Example.com website\"\nMonitor ID 780689018 ensured\n```\n\nIf the monitor doesn't already exist, it will be created.\n\nYou can use the `-c` flag to add alert contacts, just as for the `uptimerobot new` command.\n\n## Checking the version number\n\nTo see what version of the command-line client you're using, run `uptimerobot version`.\n\n## Viewing debug output\n\nWhen things aren't going quite as they should, you can add the `--debug` flag to your command line to see a dump of the HTTP request and response from the server. This is helpful if you want to report problems with the client, for example.\n\n## Using the Go library\n\nIf the command-line client doesn't do quite what you need, or if you want to use Uptime Robot API access in your own programs, import the library using:\n\n```go\nimport \"github.com/bitfield/uptimerobot/pkg\"\n```\n\nCreate a new `Client` object by calling `uptimerobot.New()` with an API key:\n\n```go\nclient = uptimerobot.New(apiKey)\n```\n\nOnce you have a client, you can use it to call various Uptime Robot API features:\n\n```go\nmonitors, err := client.AllMonitors()\nif err != nil {\n        log.Fatal(err)\n}\nfor _, m := range monitors {\n        fmt.Println(m)\n        fmt.Println()\n}\n```\n\nMost API operations use the `Monitor` struct, which looks like this:\n\n```go\ntype Monitor struct {\n\tID           int64  `json:\"id,omitempty\"`\n        FriendlyName string `json:\"friendly_name\"`\n        URL          string `json:\"url\"`\n        ...\n}\n```\n\nFor example, to delete a monitor, find the ID of the monitor you want to delete, and pass it to `DeleteMonitor()`:\n\n```go\nif err := client.DeleteMonitor(780689017); err != nil {\n        log.Fatal(err)\n}\n```\n\nTo call an Uptime Robot API verb not implemented by the `uptimerobot` library, you can use the `MakeAPICall()` method directly, passing it some suitable JSON data:\n\n```go\nr := uptimerobot.Response{}\ndata := []byte(fmt.Sprintf(\"{\\\"id\\\": \\\"%d\\\"}\", m.ID))\nif err := client.MakeAPICall(\"deleteMonitor\", \u0026r, data); err != nil {\n    log.Fatal(err)\n}\nfmt.Println(r.Monitor.ID)\n```\n\nThe API response is returned in the `Response` struct. If the call fails, `MakeAPICall()` will return the error message. Otherwise, the requested data will be available in the appropriate field of the `Response` struct:\n\n```go\ntype Response struct {\n        Stat          string         `json:\"stat\"`\n        Account       Account        `json:\"account\"`\n        Monitors      []Monitor      `json:\"monitors\"`\n        Monitor       Monitor        `json:\"monitor\"`\n        AlertContacts []AlertContact `json:\"alert_contacts\"`\n        Error         Error          `json:\"error\"`\n}\n```\n\nFor example, when creating a new monitor, the ID of the created monitor will be returned as `r.Monitor.ID`.\n\nIf things aren't working as you expect, you can use the debug facility to dump the raw request and response data from every API call. To do this, set the environment variable `UPTIMEROBOT_DEBUG`, which will dump debug information to the standard output, or set `client.Debug` to any `io.Writer` to send output to that writer.\n\nHere's an example of the debug output shown when creating a new monitor:\n\n```http\nPOST /v2/newMonitor HTTP/1.1\nHost: api.uptimerobot.com\nUser-Agent: Go-http-client/1.1\nContent-Length: 221\nContent-Type: application/json\nAccept-Encoding: gzip\n\n{\n  \"alert_contacts\": \"0335551_0_0-2416450_0_0\",\n  \"api_key\": \"XXX\",\n  \"format\": \"json\",\n  \"friendly_name\": \"Example check\",\n  \"port\": 443,\n  \"type\": 1,\n  \"url\": \"https://www.example.com\"\n}\n\nHTTP/2.0 200 OK\nAccess-Control-Allow-Origin: *\nCf-Ray: 505422654b04dbf3-LHR\nContent-Type: application/json; charset=utf-8\nDate: Mon, 12 Aug 2019 17:22:57 GMT\nEtag: W/\"33-NlNt8dOhQvno31TtQYsI0xTJ9w\"\nExpect-Ct: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\nServer: cloudflare\nSet-Cookie: __cfduid=d9ec99b8a777d9f806956432718fb5c81565630577; expires=Tue, 11-Aug-20 17:22:57 GMT; path=/; domain=.uptimerobot.com; HttpOnly\nVary: Accept-Encoding\n\n{\"stat\":\"ok\",\"monitor\":{\"id\":783263671,\"status\":1}}\n```\n\n## Bugs and feature requests\n\nIf you find a bug in the `uptimerobot` client or library, please [open an issue](https://github.com/bitfield/uptimerobot/issues). Similarly, if you'd like a feature added or improved, let me know via an issue.\n\nNot all the functionality of the Uptime Robot API is implemented yet.\n\nPull requests welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfield%2Fuptimerobot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfield%2Fuptimerobot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfield%2Fuptimerobot/lists"}