Get latest SMS (up to 2 mins)

JS Example:
1 2 3 4 5 6 7 8 9 fetch('https://api.oksms.io/api/v2/sms?phone=PHONE', { method: 'GET', headers: { 'X-API-KEY': 'YOUR-API-KEY' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error getting latest SMS:', error));
Golang Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 package main import ( "fmt" "io/ioutil" "net/http" ) func main() { client := &http.Client{} req,err := http.NewRequest("GET", "https://api.oksms.io/api/v2/sms?phone=PHONE", nil) if err != nil { fmt.Println(err) return } req.Header.Add("X-API-KEY", "YOUR-API-KEY") resp, err := client.Do(req) if err != nil { fmt.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }
Python is for kids.

API will return 404 if sms is not found
JSON response example for SMS. We also provide the code (if our regex picks it up) in the possible_code field, always validate yourself:
1 2 3 4 { "content": "Your code to access Google is", "possible_code": "123456" }

Switch slot

JS Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 fetch('https://api.oksms.io/api/v2/port', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR-API-KEY' }, body: JSON.stringify({ 'lines': [ '1-1.01', '1-2.01' ] }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error getting latest SMS:', error));
Golang Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 package main import ( "fmt" "io/ioutil" "net/http" ) func main() { client := &http.Client{} payload := strings.NewReader(`{"lines":["1-1.01","1-2.01"]}`) req,err := http.NewRequest("POST", "https://api.oksms.io/api/v2/port", payload) if err != nil { fmt.Println(err) return } req.Header.Add("X-API-KEY", "YOUR-API-KEY") resp, err := client.Do(req) if err != nil { fmt.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }