技術情報

Twitter announces their new API with free, basic and enterprise levels

After shutting down the free API access, Twitter finally announced its new API pricing structure. These three tiers include a free tier aimed primarily at content posting bots, a $100/month basic tier, and an expensive enterprise tier. According to the company, access to the Ads API is free for any level of subscription.

https://twitter.com/TwitterDev/status/1641222782594990080

The story of the Twitter API began in February when the company announced that free access to the API would end in a few days. After heavy criticism, Elon Musk said the company would offer a free tier to bots that provide “good content.” He later said the basic tier would start at $100 a month without elaborating on the level of access. After more than 45 days, the company finally provided information about its new API.

The new API offering looks like a money grab. The free tier gives you access to just 1,500 post requests per month and sign in with Twitter. The base level, considered “Enthusiast/Student”, provides 50,000 post requests and 10,000 read requests per month per app. Developers who want access to more data should apply for Enterprise Access.

Previously, with the introduction of v2 in 2020, Twitter offered multiple access tiers to developers such as Essential and Elevated, giving them access to between 500,000 and 2 million tweets per month. App makers that fall into that usage category are currently required to subscribe to an Enterprise plan.

Yuuma



Dart Object ListのKey-valueで重複を削除する方法

DartでKey-ValueによるObjectのリストから重複を削除するには、toSet()が利用できます。最初にtoSetメソッドを呼び出し、その後、再びリストに変換するだけです。

以下に例を示します。

class _Product {
  final name;
  final type;
  final price;
  _Product({
    required this.name,
    required this.type,
    required this.price,
  });

  String toJson() {
    return "{ name: $name, type: $type, price: $price}";
  }
}

toSetを呼び出してみます。

final products = [
  _Product(name: "USB", type: "A", price: 10), // same
  _Product(name: "USB", type: "A", price: 10), // same
  _Product(name: "USB", type: "B", price: 12),
  _Product(name: "USB", type: "C", price: 11),
  _Product(name: "Mouse", type: "A", price: 10),
  _Product(name: "Mouse", type: "B", price: 12), // same
  _Product(name: "Mouse", type: "B", price: 12), // same
  _Product(name: "Mouse", type: "C", price: 10),
  _Product(name: "Laptop", type: "A", price: 100),
  _Product(name: "Laptop", type: "B", price: 120), // same
  _Product(name: "Laptop", type: "B", price: 120), // same
];

print(products.length); // 11
print(products.toSet().length); // 11

toSet()で呼び出しても、同じ長さになっています。その時、hashCodeを確認してみます。

products.forEach((element) {
    print(element.hashCode);
    // 257416280
    // 1045932166
    // 730517725
    // 586146378
    // 215518337
    // 471982393
    // 775971279
    // 335683510
    // 844714385
    // 633234047
    // 1021163746
});

それぞれのhashCodeは異なっているため、hashCodeと==演算子をオーバーライドする必要があります。

class _Product {
  ...

  @override
  bool operator ==(Object other) {
    return other is _Product && other.hashCode == hashCode;
  }

  @override
  int get hashCode => Object.hash(name, type, price);
}

このクラスはリストを持ちませんから、Object.hash関数を使用しますが、リスト変数を含む場合は、代わりにObject.hashAllを使用します。

もう一度、toSetを呼び出してみます。

print(products.length); // 11
print(products.toSet().length); // 8
products.toSet().forEach((element) => print(element.toJson()));
// { name: USB, type: A, price: 10}
// { name: USB, type: B, price: 12}
// { name: USB, type: C, price: 11}
// { name: Mouse, type: A, price: 10}
// { name: Mouse, type: B, price: 12}
// { name: Mouse, type: C, price: 10}
// { name: Laptop, type: A, price: 100}
// { name: Laptop, type: B, price: 120}

なお、重複するものはここでは表示しませんでした。

金曜担当 – Ami



正規表現基礎(4)

今回はさまざまなプログラミング言語やツールで活用できる正規表現の記号を紹介します。
本記事は前回の「正規表現基礎(3)」の続きです。

続きを読む

Checking if a file already exists in the given path with Node js

Today, I would like to share about checking if a file already exists in the given path using Node js. Let’s take a look.

To check if a file already exists or not, we can perform simply by using existsSync() method of ‘fs’ module in node js. The code is as follow.

const fs = require('fs')

let filePath = "C:\\Users\\waith\\Documents\\t1ee.pdf"
if (!fs.existsSync(filePath)) {
  console.log('File does NOT exist!');
}else{
  console.log('File exists.');
}

Yes, that is it. The steps to perfom that is very simple. It is just to declare fs module and use fs.existsSync() method to check the filepath.

This is all for now. Hope you enjoy that.

By Asahi



3 Useful image manipulation libraries in Node JS

Today, I would like to share about image manipulation libraries in Node JS. Let’s take a look.

1. Canvas

Node Canvas is a very powerful image library which implements Web Canvas API. So it will be flexible for developers.

Check here for more details.

2. Sharp

Sharp is an efficient image processing library for Node JS. It is very useful for resizing, converting and editing images.

Check here for more details.

3. GraphicsMagick

GraphicsMagick is also a powerful image processing library of Node JS for many image functions.

Check here for more details.

This is all for now. Hope you enjoy that.

By Asahi




アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム