httpsms README

The project's README from github.com/NdoleStudio/httpsms. As one markdown file: README.md.

httpSMS

Web API GitHub contributors GitHub license Contributor Covenant Scrutinizer Code Quality Better Stack Badge Greptile: The War on Bugs Sponsors Discord

httpSMS is a service that lets you use your Android phone as an SMS Gateway to send and receive SMS messages. You make a request to a simple HTTP API and it triggers your Android phone to send an SMS. SMS messages received on your android phone can also be forwarded to your webhook endpoint.

Quick Start Guide 👉 https://docs.httpsms.com

header

Table Of Contents

Why?

I'm originally from Cameroon and I wanted an automated way to send and receive SMS messages using an API. Unfortunately many countries don't support the ability to buy virtual phone numbers, and I could not find a good ready-made solution that could help me send/receive SMS messages using a mobile phone using an intuitive http API.

Web UI

The web interface https://httpsms.com is built using Nuxt and Vuetify. It is hosted as a single page application on firebase. The source code is in the web directory

API

The API https://api.httpsms.com is built using Fiber, Go and CockroachDB for the database. It runs as a serverless application on Google Cloud Run. The API documentation can be found here https://api.httpsms.com/index.html

// Sending an SMS Message using Go
client := htpsms.New(htpsms.WithAPIKey(/* API Key from https://httpsms.com/settings */))

client.Messages.Send(context.Background(), &httpsms.MessageSendParams{
    Content: "This is a sample text message",
    From:    "+18005550199",
    To:      "+18005550100",
})

Android App

The Android App is a native application built using Kotlin with material design principles. This app must be installed on an Android phone before you can start sending and receiving SMS messages.

Get it on GitHub

Chat/forum

There are a few ways to get in touch with me and/or the rest of the community. Feel free to use any of these methods. Whatever works best for you:

Features

End-to-end Encryption

You can encrypt your messages end-to-end using the military grade AES-256 encryption algorithm. Your encryption key is stored only on our mobile phone so the even the server won't have any way to view the content of your SMS messages which are sent and received on your Android phone.

Webhook

If you want to build advanced integrations, we support webhooks. The httpSMS platform can forward SMS messages received on the android phone to your server using a callback URL which you provide.

Back Pressure

In-order not to abuse the SMS API on android, you can set a rate limit e.g 3 messages per minute. Such that even if you call the API to send messages to 100 people, It will only send the messages at a rate of 3 messages per minute.

Message Expiration

Sometimes it happens that the phone doesn't get the push notification in time and I can't send the SMS message. It is possible to set a timeout for which a message is valid and if a message becomes expired after the timeout elapses, you will be notified.

API Clients

Flows

Sending an SMS Message

sequenceDiagram
User->>+httpSMS API: Call /v1/messages/send API
httpSMS API-->>+Push Queue: Schedule notification about new message
httpSMS API-->>-User: Respond with 202 (Accepted)
Push Queue-->>+httpSMS API: [Async] Send notification request
httpSMS API-->>-Android App: Send push notification about new message
Android App-->>httpSMS API: [Async] Fetch message
Android App-->>Android App: Send Message using Android SMS API
Android App-->>httpSMS API: [Async] Send result of sending SMS
Android App-->>httpSMS API: [Async] Send Delivery Report

Self Host Setup - Docker

1. Setup Firebase

const firebaseConfig = {
  apiKey: "AIzaSyAKqPvj51igvvNNcRtxxxxx",
  authDomain: "httpsms-docker.firebaseapp.com",
  projectId: "httpsms-docker",
  storageBucket: "httpsms-docker.appspot.com",
  messagingSenderId: "668063041624",
  appId: "1:668063041624:web:29b9e3b702796xxxx",
  measurementId: "G-18VRYL2xxxx",
};

2. Setup SMTP Email service

The httpSMS application uses SMTP to send emails to users e.g. when your Android phone has been offline for a long period of time. You can use a service like mailtrap to create an SMTP server for development purposes.

3. Setup Cloudflare Turnstile

The message search route (/v1/messages/search) is protected by a Cloudflare Turnstile captcha to prevent abuse. You need to set up a Turnstile widget for the search messages feature to work.

  1. Go to the Cloudflare dashboard and navigate to Turnstile.
  2. Add a new site and configure it for your self-hosted domain (e.g., localhost for local development).
  3. Note down the Site Key and Secret Key — you will need them for the frontend and backend environment variables respectively.

4. Download the code

Clone the httpSMS GitHub repository

git clone https://github.com/NdoleStudio/httpsms.git

5. Setup the environment variables

cp web/.env.docker web/.env
FIREBASE_API_KEY=
FIREBASE_AUTH_DOMAIN=
FIREBASE_PROJECT_ID=
FIREBASE_STORAGE_BUCKET=
FIREBASE_MESSAGING_SENDER_ID=
FIREBASE_APP_ID=
FIREBASE_MEASUREMENT_ID=

# Cloudflare Turnstile site key from step 3
CLOUDFLARE_TURNSTILE_SITE_KEY=
cp api/.env.docker api/.env
# SMTP email server settings
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_HOST=
SMTP_PORT=

# Firebase service account credentials
FIREBASE_CREDENTIALS=

# This is the `projectId` from your firebase web config
GCP_PROJECT_ID=

# Cloudflare Turnstile secret key from step 3
CLOUDFLARE_TURNSTILE_SECRET_KEY=

6. Build and Run

docker compose up --build

7. Create the System User

[!IMPORTANT] Restart your API docker container after modifying EVENTS_QUEUE_USER_ID, and EVENTS_QUEUE_USER_API_KEY in your .env file so that the httpSMS API can pick up the changes.

8. Build the Android App.

Integration Testing

The project includes end-to-end integration tests that validate the complete SMS send/receive lifecycle. Tests run the full stack (API, PostgreSQL, Redis) in Docker alongside a phone emulator that simulates an Android device.

📖 Full documentation: tests/README.md

Quick run:

cd tests
bash generate-firebase-credentials.sh
export FIREBASE_CREDENTIALS=$(jq -c . firebase-credentials.json)
docker compose up -d --build --wait
docker compose wait seed && sleep 2
go test -v -timeout 120s ./...
docker compose down -v

Integration tests also run automatically in CI on every push/PR to main.

License

This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 - see the LICENSE file for details

httpsms (NdoleStudio/httpsms)

Searching Database…

这是什么?httpSMS 把一台 Android 手机变成 SMS 网关:你调用一个简单的 HTTP API,它就会触发手机发送短信,手机收到的短信也可以转发到你的 webhook。
这是托管服务,还是需要我自己部署的东西?它是一套可自托管的组件栈(Go API、Web 界面、Postgres、Redis),用 Docker Compose 运行,外加一个实际负责发送短信的 Android 应用。
怎么让自托管版跑起来?克隆仓库,配置 Firebase(用于向手机推送通知)、SMTP 服务和 Cloudflare Turnstile,填写 web 和 api 目录下的 .env 文件,然后运行 docker-compose.yml,在数据库中创建系统用户,最后在 Android Studio 中用你的 google-services.json 构建 Android 应用。
自托管之前需要准备哪些外部服务?你需要一个 Firebase 项目(用于 Cloud Messaging 推送通知和身份验证)、一台用于事务性邮件的 SMTP 服务器,以及一个 Cloudflare Turnstile 站点,用于给搜索端点提供验证码保护。
手机总是立即发送消息吗?不是——送达取决于手机能否及时收到推送通知,所以 README 建议设置消息过期超时,这样失败时你会收到通知,而不是无限等待。
服务器会看到我消息的内容吗?如果你启用端到端加密,消息会用 AES-256 加密,密钥只保存在你的手机上,服务器无法读取短信内容。
我可以控制短信发送的速度吗?可以。你可以设置速率限制,比如每分钟 3 条(背压),即使批量调用 API 发给 100 个收件人,也会被限流到该速率。
有没有调用 API 的客户端库?有,官方列出了 Go 和 JavaScript/TypeScript 的 API 客户端。
收到的短信数据去了哪里?Android 手机上收到的短信可以转发到你在自己服务器上配置的 webhook/回调 URL。
部署之前可以测试完整的收发流程吗?可以。项目自带端到端集成测试,会在 Docker 中运行完整的 API、PostgreSQL 和 Redis 组件栈,并同时运行一个手机模拟器,这些测试也会在 CI 中自动执行。
Size
42.9 MB
Stars
6K
Age
4y
Commits · 90 Days