Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

Twitter4J

> 编程语言
Open source

Twitter4J is an open-source Java library for the Twitter API.

2.8K stars0 likes0 views
WebsiteGitHub

About

Twitter4J is an open-source Java library for the Twitter API.

X4J

#Twitter4J is a 100% pure Java library for the Twitter API with no extra dependency.

Requirements

Java 8 or later

Dependency declaration

Add a dependency declaration to pom.xml, or build.gradle as follows:

Maven

<dependencies>
    <dependency>
        <groupId>org.twitter4j</groupId>
        <artifactId>twitter4j-core</artifactId>
        <version>4.1.2</version>
    </dependency>
</dependencies>

Gradle

dependencies {
    compile 'org.twitter4j:twitter4j-core:4.1.2'
}

Java modularity

requires org.twitter4j;

Getting started

Acquire an instance configured with twitter4j.properties, tweet "Hello Twitter API!".

twitter4j.properties

oauth.consumerKey=[consumer key]
oauth.consumerSecret=[consumer secret]
oauth.accessToken=[access token]
oauth.accessTokenSecret=[access token secret]

Main.java

import org.twitter4j.*;
public class Main {
  public static void main(String... args){
    Twitter twitter = Twitter.getInstance();
    twitter.v1().tweets().updateStatus("Hello Twitter API!");
  }
}

v1() returns TwitterV1 interface which provides various Twitter API V1.1 API resources. tweets() returns TweetsResources.

You can also get a builder object from newBuilder() method to configure the instance with code:

Main.java

import org.twitter4j.*;
public class Main {
  public static void main(String... args){
    var twitter = Twitter.newBuilder()
      .oAuthConsumer("consumer key", "consumer secret")
      .oAuthAccessToken("access token", "access token secret")
      .build();
    twitter.v1().tweets().updateStatus("Hello Twitter API!");
  }
}

License

Apache License Version 2.0

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •Java

> Tags

Java

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言