https://github.com/levelzerotechnology/directadmin-go
A library to interface with a DirectAdmin installation's API
https://github.com/levelzerotechnology/directadmin-go
api directadmin library sdk-go
Last synced: 30 days ago
JSON representation
A library to interface with a DirectAdmin installation's API
- Host: GitHub
- URL: https://github.com/levelzerotechnology/directadmin-go
- Owner: levelzerotechnology
- License: gpl-3.0
- Created: 2023-03-16T21:23:02.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-13T14:51:08.000Z (7 months ago)
- Last Synced: 2025-07-13T16:29:39.902Z (7 months ago)
- Topics: api, directadmin, library, sdk-go
- Language: Go
- Homepage:
- Size: 178 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DirectAdmin Go SDK
Interface with a DirectAdmin installation using Go.
This library supports both the legacy/default DirectAdmin API, and their new modern API still in active development.
**Note: This is in an experimental state. While it's being used in production, the library is very likely to change (
especially in-line with DA's own changes). DA features are being added as needed on our end, but PRs are always welcome!
**
**If you wonder why something has been handled unusually, it's most likely a workaround required by one of DA's many
quirks.**
## Login as Admin / Reseller / User
To open a session as an admin/reseller/user, follow the following code block:
```go
package main
import (
"time"
"github.com/levelzerotechnology/directadmin-go"
)
func main() {
api, err := directadmin.New("https://your.da.address:2222", 5*time.Second)
if err != nil {
panic(err)
}
userCtx, err := api.LoginAsUser("your_username", "some_password_or_key")
if err != nil {
panic(err)
}
usage, err := userCtx.GetMyUserUsage()
if err != nil {
panic(err)
}
userCtx.User.Usage = *usage
}
```
From here, you can call user functions via `userCtx`.
For example, if you wanted to print each of your databases to your terminal:
```go
dbs, err := userCtx.GetDatabases()
if err != nil {
log.Fatalln(err)
}
for _, db := range dbs {
fmt.Println(db.Name)
}
```
## License
BSD licensed. See the [LICENSE](LICENSE) file for details.